Java Programming Questions and Answers
The exception class is in ____ package
Which keyword is used to monitor statement for exception?
If an exception is generated in try block , then it is caught in ____ block
______ is a superclass of all exception classes.
In case of multiple catch blocks,______
Which method is used to print the description of the exception?
What is the output of following try catch block try
{ int i; return; } catch(Exception e) { System.out.println('Hello Indiaâ€); } finally { System.out.println('Hello Morbiâ€); }
What will be the output of the program? public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }
What will be the output of the program? public class Test { public static void aMethod() throws Exception { try /* Line 5 */ { throw new Exception(); /* Line 7 */ } finally /* Line 9 */ { System.out.print("finally "); /* Line 11 */ } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) /* Line 20 */ { System.out.print("exception "); } System.out.print("finished"); /* Line 24 */ } }
What will be the output of the program? public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (Exception ex) { System.out.print("B"); } finally { System.out.print("C"); } System.out.print("D"); } public static void badMethod() { throw new Error(); /* Line 22 */ } }