Java OCA OCP Practice Question 2450

Question

Examine the classes defined as follows and select the correct options. (Choose all that apply.)

class Exception1 extends RuntimeException {}
class Exception2 extends java.lang.Exception2{}
class Exception3 extends Throwable {}
class Exception4 extends java.io.FileNotFoundException{}
  • a The classes Exception1 and Exception2 are unchecked exceptions.
  • b It isn't mandatory to include the name of exception Exception1 in the throws clause of a method.
  • c You shouldn't define a custom exception class the way class Exception3 has been defined.
  • d Class Exception4 is a checked exception.
  • e All these classes will not compile successfully.


b, c, d, e

Note

Option (a) is incorrect because java.lang.Exception2 is undefined.

So class Exception1 won't compile.

Option (e) is a correct option because class Exception1 won't compile.




PreviousNext

Related