1.

If catching of base class exception is done before derived class in C++ ________________(a) It gives compile time error(b) It doesn’t run the program(c) It may give warning but not error(d) It always gives compile time errorThis question was posed to me during a job interview.My question is taken from Catching Class Types topic in section Exception Handling & Static Class Members of Object Oriented Programming

Answer»

Correct choice is (c) It may give warning but not error

Easy explanation - The compiler in C++ doesn’t IDENTIFY this as COMPILE time error and allows the execution of the PROGRAM. But, the compiler may give some warning RELATED to the catch block sequence or code unreachable.



Discussion

No Comment Found

Related InterviewSolutions