Writing Classes in AP Computer Science A
Can static methods can access and/or change the values of static variables?
Static methods can access and change the values of static variables
Static methods cannot access or change the values of static variables
Static methods can change the values of static variables, but not access them
Static methods can access the values of static variables, but not change them
Which of these can be accessed without creating an object of the class?
The constructor of the class.
An instance method of the class.
An instance variable of the class.
A static variable of the class.
If two different objects from the same class access a method that modifies a static field within that class, how does it affect subsequent access by either object?
The last modified value is reset once another object accesses it.
Both objects will observe the updated static field value.
Each object maintains its own version of the field, unaffected by others.
Only the first object accessing it retains changes while subsequent accesses show no change.
When would designating member function 'static' NOT appropriate?
Instance-dependent behavior required, reacting differently depending on the specific object used to invoke it.
Cases involving purely computational tasks dealing with no internal states whatsoever.
Situations where a large number of common operations needed frequently updated information irrelevant to individual instances.
Circumstances demanding functionality uniformly applicable regardless of whichever entity calling.
In what scenario would refactoring several related methods from being instance methods into being class (static) methods NOT make sense?
When these methods heavily rely on accessing or modifying unique instance-specific data fields frequently
When enforcing consistency in behavior across all instances without regard for individual state differences.
When simplifying collective operations or calculations applied uniformly across all objects.
When these methods provide utility functionality not dependent on any state information of specific instances.
How do changes made to a static variable from one instance of a Java Class impact other instances?
Changes result in new allocations making old references hold outdated values.
They create local copies for each instance hence changes are not visible across different objects.
All other instances observe identical changes as there's only one copy shared among them.
Other instances remain unaffected until they explicitly check for updates on shared resources.
When writing Java programs, why would you include a finally block after catch blocks?
To ensure that resources are released regardless of whether an exception was caught or not.
To prevent the compiled program from being executed if there are runtime errors detected.
To throw custom exceptions if the error is not handled in any preceding catch blocks.
To immediately stop further execution of the program if an exception occurs during operations.

How are we doing?
Give us your feedback and let us know how we can improve
What does it mean if a field is declared with both 'static' and 'final' modifiers?
The field can no longer be used within any methods in the code.
It's a constant that belongs to the entire class.
It's an unchangeable field unique to each instance of a class.
It becomes modifiable only once per instance created.
In Java, what will happen if you try to access a non-static variable from within a static method?
The variable will be initialized with a default value.
Compilation error
Runtime exception
The method returns null.
What is a characteristic of a static method in Java?
It requires an object to be instantiated before it can be used.
It can be called on a class rather than an instance of the class.
Its behavior changes every time it is called with different arguments.
It cannot access other static methods within its class.