Exception Handling in Java MCQs

@T-Bone

This question paper focuses on the "Exception Handling" of the Java programming. These Multiple Choice Questions (mcq) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

This question paper focuses on the "Exception Handling" of the Java programming. These Multiple Choice Questions (mcq) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

Questions

1. Which statement is true?

Mark the correct option

2. Which statement is true?

Mark the correct option

3. When does Exceptions in Java arises in code sequence?

Mark the correct option

4. Which of these keywords is not a part of exception handling?

Mark the correct option

5. Which of these keywords must be used to monitor for exceptions?

Mark the correct option

6. Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

Mark the correct option

7. Which of these keywords is used to manually throw an exception?

Mark the correct option

8. Which of these is a super class of all errors and exceptions in the Java language?

Mark the correct option

9. In which of the following package Exception class exist?

Mark the correct option

10. Which exception is thrown when divide by zero statement executes?

Mark the correct option

11. What is the output of this program? class Main { public static void main(String args[]) { try { System.out.print("Hello" + " " + 1 / 0); } catch(ArithmeticException e) { System.out.print("World"); } } }

Mark the correct option

12. What is the output of this program? class Main { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } }

Mark the correct option

13. What is the output of this program? class Main { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } finally { System.out.print("C"); } } }

Mark the correct option

14. What is the output of this program? class Main { public static void main(String args[]) { try { int i, sum; sum = 10; for (i = -1; i < 3 ;++i) sum = (sum / i); } catch(ArithmeticException e) { System.out.print("0"); } System.out.print(sum); } }

Mark the correct option

15. Predict the output of following Java program? class Main { public static void main(String args[]) { try { throw 10; } catch(int e) { System.out.println("Got the Exception " + e); } } }

Mark the correct option

16. What will be output for the following code? class Test extends Exception { } class Main { public static void main(String args[]) { try { throw new Test(); } catch(Test t) { System.out.println("Got the Test Exception"); } finally { System.out.println("Inside finally block "); } } }

Mark the correct option

17. Output of following Java program? class Main { public static void main(String args[]) { int x = 0; int y = 10; int z = y/x; } }

Mark the correct option

18. What will be output for the following code? class Base extends Exception {} class Derived extends Base {} public class Main { public static void main(String args[]) { try { throw new Derived(); } catch(Base b) { System.out.println("Caught base class exception"); } catch(Derived d) { System.out.println("Caught derived class exception"); } } }

Mark the correct option

19. What will be output for the following code? class Test { public static void main (String[] args) { try { int a = 0; System.out.println("a = " + a); int b = 20 / a; System.out.println("b = " + b); } catch(ArithmeticException e) { System.out.println("Divide by zero error"); } finally { System.out.println("inside the finally block"); } } }

Mark the correct option

20. What is the output of this program? class Main { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }

Mark the correct option

21. Which of these is a super class of all exceptional type classes?

Mark the correct option

22. Which of these class is related to all the exceptions that can be caught by using catch?

Mark the correct option

23. Which of these class is related to all the exceptions that cannot be caught?

Mark the correct option

24. Which of these handles the exception when no catch is used?

Mark the correct option

25. What exception thrown by parseInt() method?

Mark the correct option

26. What is the output of this program? class Main { public static void main(String args[]) { try { System.out.print("Hello" + " " + 1 / 0); } finally { System.out.print("World"); } } }

Mark the correct option

27. What is the output of this program? class Main { public static void main(String args[]) { try { int i, sum; sum = 10; for (i = -1; i < 3 ;++i) { sum = (sum / i); System.out.print(i); } } catch(ArithmeticException e) { System.out.print("0"); } } }

Mark the correct option

28. Which of these operator is used to generate an instance of an exception than can be thrown by using throw?

Mark the correct option

29. Which of these keywords is used to by the calling function to guard against the exception that is thrown by called function?

Mark the correct option

30. What is the output of this program? class Main { public static void main(String args[]) { try { System.out.print("A"); throw new NullPointerException ("Hello"); } catch(ArithmeticException e) { System.out.print("B"); } } }

Mark the correct option

31. What is the output of this program? class Main { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }

Mark the correct option

32. A single try block must be followed by which of these?

Mark the correct option

33. Which of these exceptions handles the divide by zero error?

Mark the correct option

34. Which of these exceptions will occur if we try to access the index of an array beyond its length?

Mark the correct option

35. What is the output of this program? class Main { public static void main(String args[]) { try { int a = args.length; int b = 10 / a; System.out.print(a); } catch (ArithmeticException e) { System.out.println("1"); } } }

Mark the correct option