MCQ – Java Exceptions

(Last Updated On: March 26, 2018)
Q) Types of exceptions in Java programming are
  1. Checked exception
  2. unchecked exception
  3. Both A & B
  4. None
View Answer
Answer: C

 

Q) Checked exception caught at
  1. compile time
  2. run time
  3. Both at compile and run time
  4. None
View Answer
Answer: A

Q) Unchecked exception caught at
  1. compile time
  2. run time
  3. Both at compile and run time
  4. None
View Answer
Answer: B
Unchecked exception caught at run time when we execute the java program. Unchecked java exceptions example are ArithmeticException, null pointer exception etc. let’s say at the run time in the program if a number divide by zero occurs then arithmetic exception happens.

Q) What exception can occur in the below java program if we access 5 element in the array that does not exist?
 

  1. ArrayIndexOutOfBoundsException
  2. ArithmeticException
  3. NullPointerException
  4. None
View Answer
Answer: A
ArrayIndexOutOfBoundsException unchecked exception will occur at run time when we execute the program.