Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = a / b; System.out.print("Hello"); } finally { System.out.print("World"); } } }
Q2
Which of these is a super class of all exceptional type classes?
Q3
Which of the following operators is used to generate instance of an exception which can be thrown using throw?
Q4
Which of these keywords are used for generating an exception manually?
Q5
What will be the output of the following Java program? class exception_handling { 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"); } } }
Q6
At runtime, error is recoverable.
Q7
Which of these methods return localized description of an exception?
Q8
Which part of code gets executed whether exception is caught or not?
Q9
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { System.out.print("A"); throw new NullPointerException ("Hello"); } catch(ArithmeticException e) { System.out.print("B"); } } }
Q10
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = 1; int b = 10 / a; try { if (a == 1) a = a / a - a; if (a == 2) { int c[] = {1}; c[8] = 9; } } finally { System.out.print("A"); } } catch (Exception e) { System.out.println("B"); } } }
Q11
Which of the following is a super class of all exception type classes?
Q12
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { throw new NullPointerException ("Hello"); } catch(ArithmeticException e) { System.out.print("B"); } } }
Q13
What will be the output of the following Java code? class Myexception extends Exception { int detail; Myexception(int a) { detail = a; } public String toString() { return "detail"; } } class Output { static void compute (int a) throws Myexception { throw new Myexception(a); } public static void main(String args[]) { try { compute(3); } catch(Exception e) { System.out.print("Exception"); } } }
Q14
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = a / b; System.out.print("Hello"); } catch(Exception e) { System.out.print("World"); } } }
Q15
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = args.length; int b = 10 / a; System.out.print(a); try { if (a == 1) a = a / a - a; if (a == 2) { int c = {1}; c[8] = 9; } } catch (ArrayIndexOutOfBoundException e) { System.out.println("TypeA"); } catch (ArithmeticException e) { System.out.println("TypeB"); } } } } Note : Execution command line : $ java exception_handling one
Q16
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = b / a; System.out.print("Hello"); } catch(Exception e) { System.out.print("World"); } finally { System.out.print("World"); } } }
Q17
Which of these keywords are used for the block to be examined for exceptions?
Q18
What will be the output of the following Java code? class Myexception extends Exception { int detail; Myexception(int a) { detail = a; } public String toString() { return "detail"; } } class Output { static void compute (int a) throws Myexception { throw new Myexception(a); } public static void main(String args[]) { try { compute(3); } catch(Myexception e) { System.out.print("Exception"); } } }
Q19
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { throw new NullPointerException ("Hello"); System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } }
Q20
Which of these keywords is used to by the calling function to guard against the exception that is thrown by called function?
Q21
Which of the following keyword is used by a calling function to handle exception thrown by a called function?
Q22
What will be the output of the following Java code? class exception_handling { 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"); } } } Note : Execution command line : $ java exception_handling
Q23
What is the use of try & catch?
Q24
When does Exceptions in Java arises in code sequence?
Q25
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?