Java Exception Handling Test 2 - Java Question and Answers
Finish Quiz
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
Java Exception Handling Test 2 – Java Question and Answers.ย Free Java Exception Handlingย Quiz. Take our Freeย JDBCย Onlineย Quiz – Learningย JDBCย in simple and easy steps using this beginner’s Online Test. Take free online Test Quiz 2. Java Exception Handlingย Test Quiz 2ย Question and Answers 2025. Java online Test Quiz 2. Java Exception Handlingย Quiz 2ย Free Mock Testย 2025.ย Java Exception Handlingย Test Quiz 2ย Question and Answers in PDF.ย The Java online mock test paper is free for all students.ย Java Exception Handlingย Testย is very useful for exam preparation and getting for Rank. Java Exception Handlingย Test Quiz 2ย Question and Answers in English. Java Exception Handlingย Mock test forย ย topic via Exception Handlingย Mode.ย Here we are providingย Java Exception Handlingย Mock Test in Englishย Now Test your self for โJava Exception Handlingย Testย in Englishโ Exam by using below quizโฆ
This paper has 20ย questions.
Time allowed is 25 minutes.
The Java Exception Handlingย Mock Test ย is Very helpful for all students.ย Now Scroll down below n click on โStart Quizโ or โStart Testโ andย Test yourself.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
Which of the following lists exception types from MOST specific to LEAST specific?
Correct
Incorrect
-
Question 2 of 20
2. Question
From which problems is it possible for a program to recover?
Correct
Incorrect
-
Question 3 of 20
3. Question
Which statement is FALSE about catch{} blocks?
Correct
Incorrect
-
Question 4 of 20
4. Question
What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?
Correct
Incorrect
-
Question 5 of 20
5. Question
When is a finally{} block executed?
Correct
Incorrect
-
Question 6 of 20
6. Question
What type of exception is thrown by parseInt() if it gets illegal data?
Correct
Incorrect
-
Question 7 of 20
7. Question
How many finally{} blocks may there be in a try/catch structure?
Correct
Incorrect
-
Question 8 of 20
8. Question
Is a program required to catch all exceptions that might happen?
Correct
Incorrect
-
Question 9 of 20
9. Question
Both class Error and class Exception are children of this parent:
Correct
Incorrect
-
Question 10 of 20
10. Question
Which statement is FALSE about the try{} block?
Correct
Incorrect
-
Question 11 of 20
11. Question
What type of exception is thrown by parseInt() if it gets illegal data?
Correct
If parseInt() method gets illegal data which cannot be parsed to Integer it throws NumberFormatException exception.
Incorrect
If parseInt() method gets illegal data which cannot be parsed to Integer it throws NumberFormatException exception.
-
Question 12 of 20
12. Question
Is the following code legal?
try {
} finally {
}Correct
Above code snippet is legal. It will be executed without doing anything.
try block can be used with either catch block or finally block or both.Incorrect
Above code snippet is legal. It will be executed without doing anything.
try block can be used with either catch block or finally block or both. -
Question 13 of 20
13. Question
Will this code compile?
- tryย {
- }ย catchย (Exceptionย e)ย {
- }ย catchย (ArithmeticExceptionย a)ย {
- }
Correct
The above code sippet will not compile as the sequence of catch should be subclass Exception to super class Exception.
Incorrect
The above code sippet will not compile as the sequence of catch should be subclass Exception to super class Exception.
-
Question 14 of 20
14. Question
Which statement is TRUE about the try{} block?
Correct
“The try{} block can contain loops or branches.” is the correct option.
The syntax of try-catch block is :-try{
// code snippet here
}catch(Exception e){
}finally{
}Incorrect
“The try{} block can contain loops or branches.” is the correct option.
The syntax of try-catch block is :-try{
// code snippet here
}catch(Exception e){
}finally{
} -
Question 15 of 20
15. Question
When is a finally{} block executed?
Correct
finally block is executed after try block irrespective of wheter the exception occured or not.
Incorrect
finally block is executed after try block irrespective of wheter the exception occured or not.
-
Question 16 of 20
16. Question
For the given code snippet :-
- publicย classย MyProgramย {
- ย ย ย ย ย ย ย ย ย ย ย ย ย publicย staticย voidย main(Stringย args[]){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย tryย {
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย System.out.print(“Helloย world”);
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย finallyย {
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย System.out.println(“Finallyย executing”);
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย }
- }
What is the result?
Correct
Output of above code snippet is “Hello world Finally executing“. First try block is executed and then finally block is executed.
Incorrect
Output of above code snippet is “Hello world Finally executing“. First try block is executed and then finally block is executed.
-
Question 17 of 20
17. Question
What is the result of compiling and executing the below code?
- publicย classย TryTestย {
- ย ย ย ย ย ย publicย staticย voidย main(String[]ย args)
- ย ย ย ย ย {
- ย ย ย ย ย ย ย ย ย tryย ย
- ย ย ย ย ย ย ย ย ย {
- ย ย ย ย ย ย ย ย ย ย ย return;
- ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย finallyย ย
- ย ย ย ย ย ย ย ย {
- ย ย ย ย ย ย ย ย ย ย ย ย System.out.println(“Finally”);
- ย ย ย ย ย ย ย ย }
- ย ย ย ย ย }
- ย ย }
Correct
finally block is executed everytime. The only way to escape finally is to call System.exit().
Hence for above code snippet “Finally” is printed.
Incorrect
finally block is executed everytime. The only way to escape finally is to call System.exit().
Hence for above code snippet “Finally” is printed.
-
Question 18 of 20
18. Question
What will be the output?
- publicย classย Test2{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย publicย staticย voidย main(Stringย args[]){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย System.out.println(method());
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย publicย staticย intย method(){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย try{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย throwย newย Exception();
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย returnย 1;
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย catch(Exceptionย e){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย returnย 2;
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย finally{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย returnย 3;
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย }
Choose the one below:
Correct
In the above code snippet an exception is thrown at line 6 which will give a compile time error because compiler will never be able to execute line 7 and report as unreachable code as an error.
Incorrect
In the above code snippet an exception is thrown at line 6 which will give a compile time error because compiler will never be able to execute line 7 and report as unreachable code as an error.
-
Question 19 of 20
19. Question
What will be the output?
- publicย classย Test2{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย publicย staticย voidย main(Stringย args[]){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย System.out.println(method());
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย publicย staticย intย method(){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย try{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย throwย newย Exception();
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย catch(Exceptionย e){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย returnย 2;
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย finally{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย returnย 3;
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- }
Choose the one below:
Correct
finally block is executed everytime. The only way to escape finally is to call System.exit().
When above code snippet is executed “3” is displayed because at last finally is executed and it returns 3.Incorrect
finally block is executed everytime. The only way to escape finally is to call System.exit().
When above code snippet is executed “3” is displayed because at last finally is executed and it returns 3. -
Question 20 of 20
20. Question
What will be the output?
- importย java.io.IOException;
- ย ย ย ย ย ย ย ย publicย classย Test5{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย publicย staticย voidย main(Stringย args[]){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย try{
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย throwย newย IOException();
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย catch(Exceptionย e){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย System.out.println(“Excepion”);
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย catch(IOExceptionย e){
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย System.out.println(“IOExcepion”);
- ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย }
- ย ย ย ย ย ย ย ย ย ย }
- }
Choose the one below:
Correct
The above code sippet will not compile as the sequence of catch should be subclass Exception to super class Exception.
Incorrect
The above code sippet will not compile as the sequence of catch should be subclass Exception to super class Exception.