Java OCA OCP Practice Question 2755

Question

Given the following set of classes:

class Exception A extends Exception {}

class Exception B extends A {}

class Exception C extends A {}

class Exception D extends C {}

What is the correct sequence of catch blocks for the following try block:

try {
  // method throws an exception of the above types
}
  • a. Catch A, B, C, and D
  • b. Catch D, C, B, and A
  • c. Catch D, B, C, and A
  • d. Catch C, D, B, and A


b and c

Note

The derived most class should be caught first.

The order of classes at the same hierarchy level is not important.




PreviousNext

Related