Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Exception handling is a critical concept in Java, acting as a safety net for your programs. Imagine building a complex system: without proper safeguards, a single unexpected error could bring the whole thing crashing down.
Exception handling empowers you to anticipate and gracefully manage these unforeseen circumstances during program execution. By effectively handling exceptions, you can prevent your program from abruptly terminating and maintain its overall stability. This ensures a more robust and user-friendly experience.
This quiz is specifically designed to test your understanding of key exception handling principles in Java. By tackling these questions, you’ll gain valuable insights into how to build resilient and reliable Java applications.
Quiz Summary
0 of 15 Questions completed
Questions:
Information
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 must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
Which of the following is not a checked exception ?
CorrectIncorrect -
Question 2 of 15
2. Question
class Exceptions {
public static void main ( String args [ ] )
{
int a = 2, b = 2 , c = 3;
int d = a-b;
float e = c/d;
System.out.println(e);
}
}
CorrectIncorrect -
Question 3 of 15
3. Question
class Arrays {
public static void main ( String args [ ] )
{
int numbers[ ] = { 1 , 2 , 3 };
system.out.println(numbers[3]);
}
}
CorrectIncorrect -
Question 4 of 15
4. Question
Classes which inherit runtime expressions and are checked only at runtime are known as ?
CorrectIncorrect -
Question 5 of 15
5. Question
class Sample {
public static void main ( String args [ ] )
{
try {
String data = null;
if(“DataFlair”.isequals(data)) {
System.out.println(“The String is DataFlair”);
}
}
catch(Null pointer exception exception) {
}
finally{
System.out.println(“Finally block is always executed”);
}
}
CorrectIncorrect -
Question 6 of 15
6. Question
class ExceptionExample {
public static void main ( String args [ ] )
{
try {
Scanner sc = new Scanner(System.in);
String a = “DataFlair”;
a = Integer.parseInt(a);
}
catch(Number format expression e) {
System.out.println(e);
}
}
}
CorrectIncorrect -
Question 7 of 15
7. Question
Which keyword in Exception handling is used to define exceptions and it specifies that there may occur an exception in the method ?
CorrectIncorrect -
Question 8 of 15
8. Question
Class sample {
public static void main ( String args [ ] )
{
String data = null;
System.out.println(data.length());
}
}
CorrectIncorrect -
Question 9 of 15
9. Question
Which of the following is a sample for File not found exception ?
CorrectIncorrect -
Question 10 of 15
10. Question
Which exception in Java is thrown when a thread in process is interrupted ?
CorrectIncorrect -
Question 11 of 15
11. Question
class Main {
public static void main ( String args [ ] )
{
try {
class.exception sample(“Found an exception”);
}
finally {
System.out.println(‘There may not may not be exception “);
}
}
}
CorrectIncorrect -
Question 12 of 15
12. Question
class ExceptionHandling {
public static void main ( String args [ ] )
{
try {
int values[ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }’
System.out.println(values[9]);
try {
System.out.println(values[3]/0);
}
catch(Arithmetic Exception exception1) {
System.out.println(“Arithmetic exception”);
}
catch(Arrayoutofbound Exception exception2) {
System.out.println(“Arrayoutof bound Exception”)’
}
}
}
CorrectIncorrect -
Question 13 of 15
13. Question
Which block of code is executed always whether the exception is handled or not ?
CorrectIncorrect -
Question 14 of 15
14. Question
class Example {
public static void main ( String args [ ] )
{
try {
Example obj = new Example();
obj.callmethod();
}
}
}
CorrectIncorrect -
Question 15 of 15
15. Question
class Finallyblock {
public static void main ( String args [ ] )
{
try {
int a = 10 , b = 20 , c = 30;
System.out.println(c-(a+b);
}
catch(Arithmetic Exception e) {
}
finally {
System.out.println(“Exceptions are raised”);
}
}
}
CorrectIncorrect
Summary:
This quiz on exception handling in Java challenges you with various multiple-choice questions to assess your grasp of core concepts. By attempting the quiz, you’ve had the opportunity to identify areas of strength and potential weaknesses in your knowledge of exception handling mechanisms like try-catch blocks, throws clauses, and different types of exceptions (checked vs. unchecked).
Remember, exception handling is a crucial skill for any Java developer. If you encounter difficulties with some questions, don’t be discouraged! Utilize the wealth of online resources available, such as tutorials, practice problems, and online communities, to further solidify your understanding and become a more proficient Java programmer.
