Skip to content
Sharp

Object-oriented programming · interview question

In Java, what is the effect of declaring a field as 'final'?

Multiple choiceEasychapter-2-curatedpremiumoopfields-and-state
Choose one answer
Answer and explanation

Correct answer

A. The field can be assigned only once

Why

Declaring a field as 'final' means that its value can be assigned only once, typically in the constructor or at the point of declaration, ensuring the value remains constant throughout the object's lifecycle.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →