Skip to content
Sharp

Object-oriented programming · interview question

Why does a constructor in a Java class matter in practice?

Multiple choiceEasychapter-2-curatedpremiumoopconstructors
Choose one answer
Answer and explanation

Correct answer

A. To initialize an object when it is created

Why

A constructor is a special method invoked when an object is created, and its main purpose is to initialize the object's fields with default or specified values.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →