1.

Which among the following is true?(a) Only the base class catch blocks are important(b) Only the derived class catch blocks are important(c) Both the base and derived class catch blocks are important(d) If base and derived classes both produce exceptions, program doesn’t runI got this question in homework.Asked question is from Catching Class Types topic in portion Exception Handling & Static Class Members of Object Oriented Programming

Answer»

Right option is (c) Both the base and derived class CATCH blocks are important

The best I can explain: The PURPOSE of EXCEPTION handling is to handle the unexpected errors in the program. If base class might PRODUCE some error then its catch block MUST be given and if the derived class might produce some error then it must be given a specific catch block too.



Discussion

No Comment Found

Related InterviewSolutions