Skip to content
Sharp

Object-oriented programming · interview question

Why do teams use constructors in a Java class in production code?

Multiple choiceMediumchapter-2-curatedpremiumoopclasses-and-objects
Choose one answer
Answer and explanation

Correct answer

C. To initialize objects upon creation

Why

Constructors are special methods in Java used to initialize objects when they are created. They set initial values for the object's fields and prepare the object for use.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →