1.

Which among the following is true for class exceptions?(a) Only base class can give rise to exceptions(b) Only derived class can give rise to exceptions(c) Either base class or derived class may produce exceptions(d) Both base class and derived class may produce exceptionsThe question was posed to me in a job interview.I would like to ask this question from Catching Class Types topic in chapter Exception Handling & Static Class Members of Object Oriented Programming

Answer»

Correct answer is (d) Both BASE class and derived class may PRODUCE exceptions

For explanation: It’s not mandatory that either base class or derived class can give rise to exceptions. The exceptions might GET produced from any class. The exceptions depends on code.



Discussion

No Comment Found

Related InterviewSolutions