Skip to content
Sharp

Object-oriented programming · interview question

Why might it be problematic to perform complex logic in a constructor?

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

Correct answer

B. It may lead to runtime exceptions during object creation.

Why

Complex logic in a constructor can lead to runtime exceptions, which can be problematic because it may result in partially initialized objects and make debugging difficult.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →