Q:
Java find output programs (Exception Handling) | set 1
belongs to collection: Java find output programs
Java find output programs
- Java find output programs (Data Types) | set 1
- Java find output programs (Data Types) | set 2
- Java find output programs (Data Types) | set 3
- Java find output programs (Operators) | set 1
- Java find output programs (Operators) | set 2
- Java find output programs (Operators) | set 3
- Java find output programs (if else) | set 1
- Java find output programs (if else) | set 3
- Java find output programs (switch case) | set 1
- Java find output programs (switch case) | set 2
- Java find output programs (switch case) | set 3
- Java find output programs (Loops) | set 1
- Java find output programs (Loops) | set 2
- Java find output programs (Loops) | set 3
- Java find output programs (Arrays) | set 1
- Java find output programs (Arrays) | set 2
- Java find output programs (Arrays) | set 3
- Java find output programs (this Keyword) | set 1
- Java find output programs (final Keyword) | set 1
- Java find output programs (final Keyword) | set 2
- Java find output programs (static Keyword) | set 1
- Java find output programs (static Keyword) | set 2
- Java find output programs (Parameter Passing) | set 1
- Java find output programs (Class and Objects) | set 1
- Java find output programs (Class and Objects) | set 2
- Java find output programs (Class and Objects) | set 3
- Java find output programs (Constructor & Destructor) | set 1
- Java find output programs (Constructor & Destructor) | set 2
- Java find output programs (Constructor & Destructor) | set 3
- Java find output programs (Inheritance) | set 1
- Java find output programs (Inheritance) | set 2
- Java find output programs (Inheritance) | set 3
- Java find output programs (Interface) | set 1
- Java find output programs (Interface) | set 2
- Java find output programs (Interface) | set 3
- Java find output programs (Overloading) | set 1
- Java find output programs (Overloading) | set 2
- Java find output programs (Overriding) | set 1
- Java find output programs (Overriding) | set 2
- Java find output programs (Overriding) | set 3
- Java find output programs (Exception Handling) | set 1
- Java find output programs (Exception Handling) | set 2
- Java find output programs (Exception Handling) | set 3
- Java find output programs (Enumeration) | set 1
- Java find output programs (Enumeration) | set 2
- Java find output programs (Autoboxing & Unboxing) | set 1
- Java find output programs (Autoboxing & Unboxing) | set 2
- Find output programs (Java String class)
- Find Output of Java program - 1 (Mixed topics)
- Find Output of Java program - 2 (Mixed topics)
- Java find output programs (if else) | set 2
Answer Question 1:
Output:
Explanation:
The above program will generate syntax error because we cannot use the try block without catch or finally block in Java program.
Answer Question 2:
Output:
Explanation:
In the above program, we created a class ExpEx class that contains the main() method. Here, we created try and finally block. The try block generated divide by zero exception. But we also used finally block, and as we know that finally will always execute after try block if it is defined.
Answer Question 3:
Output:
Explanation:
In the above program, we created a class ExpEx class that contains the main() method. Here, we created try and catch block.
The try block generated divide by zero exception because here we divided the local variable num1 by num2 and num2 contains value 0. Then generated exception caught by catch block. Then we print the exception object on the console screen.
Answer Question 4:
Output:
Explanation:
The above program will generate syntax error because here we used two catch blocks but "catch (Exception e)" will catch all type exception because Exception class is the superclass for all type of exceptions in Java, but we also define "catch (ArithmeticException e)" block, which is not required. That's why the above program will generate a syntax error.
Answer Question 5:
Output:
Explanation:
In the above program, we declared three local variables num1, num2, and num3 initialized with 50, 0, and 0 respectively.
num3 = num1/num2; num3 = 50/0;
The above statement will generate a divide by zero exception that will be caught by the "catch (ArithmeticException e)" block. Then we printed the exception using object 'e' on the console screen.
Here, we also defined the "catch (Exception e)" block, which is not required because the above code will generate only divide by zero exception.
need an explanation for this answer? contact us directly to get an explanation for this answer