It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Mock: Field declaration Q 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic

Dan's Mock: Field declaration Q 7

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Question 7
Which of the following statements are true?
a. The value of a final field can not be assigned more than once.
b. The value of a final field can be assigned at any time or not at all.
c. A final field that is not assigned a value at compile time is called a blank final variable.
d. Only static variables can be declared final.
e. A blank final variable that is static must be definitely assigned in a static initializer.
f. By the end of the instance construction process all blank final instance variables must be definitely assigned.
g. A field can not be declared both final and volatile.
h. None of the above.

One of the correct answers listed is c. I would agree if a final field referes to an instance final field only. Not true for final static field.
Steve Lovelace
Ranch Hand

Joined: Sep 03, 2003
Posts: 125
I agree with Barkat but would go further.
A blank final is a final variable whose declaration lacks an initializer. - JLS 4.5.4
Many final fields have initializers which execute at run time. They are not blank finals AND the compiler does not assign values to them. So answer c is just plain false.

The Inner that is named is not the true Inner.
I agree. Here's the link:
subject: Dan's Mock: Field declaration Q 7
jQuery in Action, 3rd edition