Ask Question
3 September, 20:26

11.19 (Constructor Failure) Write a program that shows a constructor passing information about constructor failure to an exception handler. Define class SomeClass, which throws an Exception in the constructor. Your program should try to create an object of type SomeClass and catch the exception that's thrown from the constructor

+2
Answers (1)
  1. 3 September, 23:58
    0
    You absolutely should throw an exception from a constructor if you're unable to create a valid object. This allows you to provide proper invariants in your class ... Throw an exception if you're unable to initialize the object in the constructor, one example are illegal arguments.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “11.19 (Constructor Failure) Write a program that shows a constructor passing information about constructor failure to an exception handler. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers