Skip to content
Sharp

Object-oriented programming · interview question

What problem can occur if a constructor performs complex logic or throws exceptions?

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

Correct answer

A. The object may be left in an inconsistent state

Why

Complex logic or exceptions in a constructor can leave the object in an inconsistent or partially initialized state, which can lead to runtime errors or improper object behavior.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →