Which among the following is true?

Which among the following is true?
A. If catch block of base class is written first, it is compile time error
B. If catch block of base class is written first, it is run time error
C. If catch block of base class is written first, derived class catch block can’t be reached
D. If catch block of base class is written first, only derived class catch block is executed
 
Answer: c
Explanation: If the catch block of the base class is defined first and then the derived class catch block is given. The code becomes unreachable. Hence the derived class catch block must be written first.
 

Tìm kiếm

Back
Top