Skip to content
Sharp

Object-oriented programming · interview question

What happens if a Java class has a constructor with parameters but no default constructor?

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

Correct answer

B. The class cannot be instantiated without arguments.

Why

If a class has a custom constructor with parameters and no default constructor, it cannot be instantiated without providing arguments that match one of the existing constructors.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →