1. What will be the output of the program? try { int x = 0; int y = 5 / x; } catch (Exception e) { System.out.println("Exception"); } catch (ArithmeticException ae) { System.out.println(" Arithmetic Exception"); } System.out.println("finished");





Ask Your Doubts Here

Type in
(Press Ctrl+g to toggle between English and the chosen language)

Comments

  • By: guest on 02 Jun 2017 01.26 am
    Compilation fails because ArithmeticException has already been caught. ArithmeticException is a subclass of java.lang.Exception, by time the ArithmeticException has been specified it has already been caught by the Exception class. If ArithmeticException appears before Exception, then the file will compile. When catching exceptions the more specific exceptions must be listed before the more general (the subclasses must be caught before the superclasses).
Show Similar Question And Answers
QA->Name the translatory program which translates the high level language into machine language before running the program?....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
MCQ->What will be the output of the program? try { int x = 0; int y = 5 / x; } catch (Exception e) { System.out.println("Exception"); } catch (ArithmeticException ae) { System.out.println(" Arithmetic Exception"); } System.out.println("finished");....
MCQ->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 / } }....
MCQ->What will be the output of the program? class Exc0 extends Exception { } class Exc1 extends Exc0 { } / Line 2 / public class Test { public static void main(String args[]) { try { throw new Exc1(); / Line 9 / } catch (Exc0 e0) / Line 11 / { System.out.println("Ex0 caught"); } catch (Exception e) { System.out.println("exception caught"); } } }....
MCQ->Which of the following statements are correct about the exception reported below? Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array. at IndiabixConsoleApplication.Program.Main(String[] args) in D:\ConsoleApplication\Program.cs:line 14 The program did not handle an exception called IndexOutOfRangeException. The program execution continued after the exception occurred. The exception occurred in line number 14. In line number 14, the program attempted to access an array element which was beyond the bounds of the array. The CLR could not handle the exception.....
MCQ->Which of the following statements are correct about exception handling in C#.NET? try blocks cannot be nested. In one function, there can be only one try block. An exception must be caught in the same function in which it is thrown. All values set up in the exception object are available in the catch block. While throwing a user-defined exception multiple values can be set in the exception, object.....
Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution