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 2024. Java online Test Quiz 2. Java Exception Handling Quiz 2 Free Mock Test 2024. 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.