AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
Java Programming
The exception class is in ____ package
java.file
java.io
java.lang
java.util
Which keyword is used to monitor statement for exception?
try
catch
throw
throws
If an exception is generated in try block , then it is caught in ____ block
finally
______ is a superclass of all exception classes.
Exception
throwable
RuntimeException
IOException
In case of multiple catch blocks,______
The superclass exception must be caught first
The superclass exception can't be caught first
Either super or subclass can be caught first
None of these
Which method is used to print the description of the exception?
printStackTrace()
printExceptionMessage()
printStackMessage()
printExceptionTrace()
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â€); }
Hello India
Hello India Hello Morbi
Hello Morbi
the program will return without printing anything
What will be the output of the program? public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }
Finally
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
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 */ } }
exception finished
finally exception finished
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 */ } }
ABCD
C is printed before exiting with an error message
BC is printed before exiting with an error message
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies