1.

If both base and derived class caught exceptions ______________(a) Then catch block of derived class must be defined before base class(b) Then catch block of base class must be defined before the derived class(c) Then catch block of base and derived classes doesn’t matter(d) Then catch block of base and derived classes are not mandatory to be definedThe question was posed to me during a job interview.This key question is from Catching Class Types in section Exception Handling & Static Class Members of Object Oriented Programming

Answer»

The correct option is (a) Then catch block of derived class must be DEFINED before base class

The EXPLANATION is: It is a condition for WRITING the catch BLOCKS for base and derived classes. It is mandatory to write derived class catch block first because the errors produced by the derived class must be handled first.



Discussion

No Comment Found

Related InterviewSolutions