Java OCA OCP Practice Question 409

Question

Identify the exceptions that are usually thrown by the JVM and the exceptions usually thrown by an application.

Select 1 option

A.        JVM  : IllegalStateException, IllegalArgumentException 
  Application  :  ClassCastException, NullPointerException, SecurityException 

B.        JVM  : IllegalStateException, IllegalArgumentException, ClassCastException, 
  Application  :   NullPointerException, SecurityException 

C.        JVM  : IllegalStateException, IllegalArgumentException, ClassCastException, NullPointerException 
  Application  :  SecurityException 

D.        JVM  : ClassCastException, NullPointerException, SecurityException 
  Application  :  IllegalStateException, IllegalArgumentException 

E.        JVM  : ClassCastException, NullPointerException 
  Application  :  IllegalStateException, IllegalArgumentException, SecurityException 

F.        JVM  : ClassCastException, NullPointerException, IllegalStateException 
  Application  :  IllegalArgumentException, SecurityException 


Correct Option is  : D

Note

A quick way to determine who should throw an exception is to see if the exception extends java.lang.Error.

Errors are always thrown only by the JVM.

RuntimeException is thrown by the JVM.

It is ok for an application code to throw a RuntimeException if it makes sense for the application to throw a RuntimeException in a given situation.




PreviousNext

Related