Skip to content
Sharp

Object-oriented programming · interview question

What happens if a constructor is private in a Java class?

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

Correct answer

D. Objects cannot be instantiated from outside the class

Why

A private constructor restricts object creation from outside the class, often used in singleton patterns or utility classes to prevent instantiation.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →