Exam 2 (2017) Flashcards
If the garbage collector stops working which of the following can eventually be exhausted if we continue
creating objects. Circle all that apply.
a. Stack
b. Heap
c. Area where static variable resides.
d. None of the above.
b. heap
A method should be defined as static if (circle all that apply):
a. Makes no reference to instance variables.
b. Makes a reference to at least one instance variable.
c. Makes a reference to static method.
d. None of the above.
a. Makes no reference to instance variables.
Which of the following represents “no address”? Circle all that apply.
a. 0
b. null
c. false
d. None of the above.
b. null
How many objects are present in the following code fragment?
StringBuffer b;
int x = 10;
Number of Objects: ____
0
When is the code associated with a finally block executed?
a. Only when the exception occurs.
b. Always
c. Only if no exception occurs.
d. None of the above.
b. Always
What is the actual task a constructor method performs?
a. Creating the object in the stack.
b. Initializing the object.
c. Moving the object from the stack to the heap.
d. None of the above.
b. Initializing the object.
Which of the following applies to the “this” reference?
a. It is a reference to the current object.
b. Can be used by both static and non-static methods.
c. It is initialized for you.
d. None of the above.
a. and c.