Exam 2 (2011) Flashcards
Name one class discussed in class that is immutable.
Strings
When should we define a method as static?
If it makes no reference to instance variables.
What is the default value of reference instance variables of a class?
null
When is space for a local integer variable allocated and when is it recovered?
Allocated: when the method is called; recovered: when the method finishes
Why do we never use == to compare floating point numbers?
Because floating point numbers are approximations
When is the finally block associated with exceptions executed?
Always
In which area of memory are objects created?
Heap
When should we define a constant as a static constant? In other words, when should we use
static final vs. final while defining a constant?
We should use static when all instances of the class will use the same constant value