← Quiz: static, final and Nested Classes: all 10 questions
Quiz: static, final and Nested Classes · Question 4 of 10
Which statement about a blank final field is correct?
Which statement about a blank final field is correct?
- A.It can be changed in any method
- B.It must be assigned exactly once, in every constructor (or at declaration)
- C.It is automatically set to 0 and can never be assigned
- D.It must also be static
Answer & explanation
Correct answer: It must be assigned exactly once, in every constructor (or at declaration)
A final field without a value must be given one exactly once during construction.
Can you get the rest right without peeking?
Take the timed Quiz: static, final and Nested Classes quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →