Practice mode Java

What must happen to a final instance field that has no initialiser in its declaration?

Correct answer D. It must be definitely assigned by the end of every constructor

Explanation

A blank final instance field must be definitely assigned at the end of every constructor, or the class fails to compile. An instance initialiser block can also do this. Ordinary methods may never assign it, and the default value does not count as an assignment. This pattern lets each object hold its own constant value.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.