Q:
Java find output programs (Exception Handling) | set 2
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:
In the above program, we created an ExpEx class that contains the main() method. Here, we created an integer array with 5 elements, and we also created an integer variable loop initialized with 0. Then we used the for loop to print array elements. But here we accessed array element at index 5, which is not exist in the array that's why the ArrayIndexOutOfBoundException exception generated and caught by catch block and print appropriate exception message on the console screen.
Answer Question 2:
Output:
Explanation:
The above program will generate syntax error because Exception class does not contain method message() that's why syntax error gets generated.
The Exception class contains the getMessage() method to get exception messages.
Answer Question 3:
Output:
Explanation:
The above program will generate a syntax error because through is not any built-in keyword in Java. We need to use the throw keyword to throw an exception explicitly.
Answer Question 4:
Output:
Explanation:
In the above program, we created an ExpEx class that contains the main() method. Here, we created the object OB of ArithmeticException class then throw the object OB that will be caught by the catch block and then print the message "My Exception" using getMessage() method of Exception class on the console screen.
Answer Question 5:
Output:
Explanation:
The above program will generate a syntax error because of the below statement,
OB.setMessage("User define exception");
In the above statement we used setMessage() method but Exception class does not contain setMessage(), that's why syntax error gets generated.
need an explanation for this answer? contact us directly to get an explanation for this answer