Skip to content
Sharp

Object-oriented programming · interview question

Why does a constructor in a Java class matter in this design?

Multiple choiceEasychapter-2-curatedpremiumoopbasic-modeling
Choose one answer
Answer and explanation

Correct answer

D. To initialize a new object.

Why

A constructor is a special method in a class that is called when an object is instantiated. It initializes the new object and sets initial values for its fields.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →