Exam 2 (2017) Flashcards

1
Q

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.

A

b. heap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

a. Makes no reference to instance variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following represents “no address”? Circle all that apply.

a. 0
b. null
c. false
d. None of the above.

A

b. null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How many objects are present in the following code fragment?

StringBuffer b;
int x = 10;
Number of Objects: ____

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.

A

b. Always

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

b. Initializing the object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

a. and c.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly