Question 1. Which exception is thrown when divide by zero statement executes?
NumberFormatException
ArithmeticException
NullPointerException
None of these
Explanation:-
Answer: Option B. -> ArithmeticException
Question 2. In which of the following package Exception class exist?
java.util
java.file
java.io
java.lang
java.net
Explanation:-
Answer: Option D. -> java.lang
Question 3. Exception generated in try block is caught in ........... block.
catch
throw
throws
finally
Explanation:-
Answer: Option A. -> catch
Question 4. Which keyword is used to explicitly throw an exception?
try
throwing
catch
throw
Explanation:-
Answer: Option D. -> throw
Question 5. The class at the top of exception class hierarchy is .................
ArithmeticException
Throwable
Object
Exception
Explanation:-
Answer: Option B. -> Throwable
Question 6. Which keyword is used to specify the exception thrown by method?
catch
throws
finally
throw
Explanation:-
Answer: Option B. -> throws
Question 7. Which of the following blocks execute compulsorily whether exception is caught or not.
finally
catch
throws
throw
Explanation:-
Answer: Option A. -> finally
Question 8. What happen in case of multiple catch blocks?
Either super or subclass can be caught first.
The superclass exception must be caught first.
The superclass exception cannot caught first.
None of these
Explanation:-
Answer: Option C. -> The superclass exception cannot caught first.
Question 9. What is the output of the following program code? public class Test{ public static void main(String args[]){ try{ int i; return; } catch(Exception e){ System.out.print("inCatchBlock"); } finally{ System.out.println("inFinallyBlock"); } } }
inCatchBlock
inCatchBlock inFinallyBlock
inFinallyBlock
The program will return without printing anything
Explanation:-
Answer: Option C. -> inFinallyBlock
Question 10. Which exception is thrown when an array element is accessed beyond the array size?
ArrayElementOutOfBounds
ArrayIndexOutOfBoundsException
ArrayIndexOutOfBounds
None of these
Explanation:-
Answer: Option B. -> ArrayIndexOutOfBoundsException