Exam 2 (2011) Flashcards

1
Q

Name one class discussed in class that is immutable.

A

Strings

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

When should we define a method as static?

A

If it makes no reference to instance variables.

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

What is the default value of reference instance variables of a class?

A

null

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

When is space for a local integer variable allocated and when is it recovered?

A

Allocated: when the method is called; recovered: when the method finishes

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

Why do we never use == to compare floating point numbers?

A

Because floating point numbers are approximations

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

When is the finally block associated with exceptions executed?

A

Always

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

In which area of memory are objects created?

A

Heap

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

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?

A

We should use static when all instances of the class will use the same constant value

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