Table of Contents
Exception Handling in Java: A Comprehensive Guide
🔒 Please log in to unlock this course.
If you require additional resources, consider purchasing: ICSE Computer Applications Class 10 – Previous Year Question Papers & Solutions (Java Fundamentals)
Related Questions
Question 1
What is a finally block? When and how is it used? Give an example.
Locked. Enroll to open this question.
Question 2
Name the block that encloses the code that may encounter anomalous situations.
Locked. Enroll to open this question.
Question 3
How will you handle logical errors?
Locked. Enroll to open this question.
Question 4
How will you handle compile-time errors?
Locked. Enroll to open this question.
Question 5
What are logical errors? Why are they hard to find?
Locked. Enroll to open this question.
Question 6
What are the types of compile-time errors?
Locked. Enroll to open this question.
Question 7
How are compile-time errors different from run-time errors?
Locked. Enroll to open this question.
Question 8
What are program errors? What are the types of program errors?
Locked. Enroll to open this question.
Question 9
What would be printed by the following code segment if someValue equals 1000?
Locked. Enroll to open this question.
Question 10
What is the difference between throw and throws clause?
Locked. Enroll to open this question.
Question 11
What is the difference between Exception and Error?
Locked. Enroll to open this question.
Question 12
How does a try statement determine which catch clause should be used to handle an exception?
Locked. Enroll to open this question.
Question 13
What happens if a try-catch-finally statement does not have a catch clause to handle an exception…
Locked. Enroll to open this question.
Question 14
What class of exceptions are generated by the Java run-time system?
Locked. Enroll to open this question.
Question 15
Can an exception be rethrown?
Locked. Enroll to open this question.
Question 16
What classes of exceptions may be caught by a catch clause?
Locked. Enroll to open this question.
Question 17
What is the purpose of the finally clause in a try-catch-finally statement?
Locked. Enroll to open this question.
Question 18
What happens when you run a program that creates an array of ints and then sets a value beyond its…
Locked. Enroll to open this question.
Question 19
In which block can you throw the exception?
Locked. Enroll to open this question.
Question 20
Which block traps and handles an exception?
Locked. Enroll to open this question.
Question 21
Create a try block that can generate three types of exceptions and handle them with multiple catch…
Locked. Enroll to open this question.
Question 22
What line of a given program will throw FileNotFoundException?
Locked. Enroll to open this question.
Question 23
Write a try/catch block that throws an Exception if the value of variable X is less than zero. The…
Locked. Enroll to open this question.
Question 24
Which code fragment will throw an ArrayIndexOutOfBoundsException?
Locked. Enroll to open this question.
Question 25
Which of the following code fragments will throw an ArrayIndexOutOfBoundsException?
Locked. Enroll to open this question.
Question 26
What is the throws keyword, and how does it differ from the throw keyword?
Locked. Enroll to open this question.
Question 27
What type of exceptions do not require the caller to explicitly handle them?
Locked. Enroll to open this question.
Question 28
What type of exceptions require the caller to explicitly handle them?
Locked. Enroll to open this question.
Question 29
What is the root class for all exceptions?
Locked. Enroll to open this question.
Question 30
How do you handle an exception? Describe the keyword try. How is it used?
Locked. Enroll to open this question.
Question 31
How do you throw an exception?
Locked. Enroll to open this question.
Question 32
Why is exception handling necessary?
Locked. Enroll to open this question.
Question 33
What is the role of (i) throws keyword ? (ii) throw keyword ?
Locked. Enroll to open this question.
Question 34
IOException is subclass of which exception class?
Locked. Enroll to open this question.
Question 35
NumberFormatException is subclass of which exception class?
Locked. Enroll to open this question.
Question 36
Which block is always executed no matter which exception is thrown?
Locked. Enroll to open this question.
Question 37
Can one catch block sufficiently trap and handle multiple exceptions?
Locked. Enroll to open this question.
Question 38
What are the three ways that an exception can be generated?
Locked. Enroll to open this question.
Question 39
What are the two direct subclasses of the Throwable class?
Locked. Enroll to open this question.
Question 40
Which of the following Java programs will result in a runtime error, and why? public class…
Locked. Enroll to open this question.
Question 41
Write general syntax of try-catch block
Locked. Enroll to open this question.
Question 42
What is the difference between error and an exception?
Locked. Enroll to open this question.
Question 43
Variable of the boolean type is automatically initialized as?
Locked. Enroll to open this question.
Question 44
Which arithmetic operations can result in the throwing of an ArithmeticException?
Locked. Enroll to open this question.
Question 45
What class of exceptions are generated by the Java run-time system?
Locked. Enroll to open this question.
Question 46
When ArithmeticException is thrown?
Locked. Enroll to open this question.
Question 47
When is the ArrayStoreException thrown?
Locked. Enroll to open this question.
Question 48
Does it matter in what order catch statements for FileNotFoundException and IOException are written?
Locked. Enroll to open this question.
Question 49
What is NullPointerException?
Locked. Enroll to open this question.
Question 50
What things should be kept in mind while creating your own exceptions in Java?
Locked. Enroll to open this question.
Question 51
How finally used under Exception Handling?
Locked. Enroll to open this question.
Question 52
When throw keyword is used?
Locked. Enroll to open this question.
Question 53
When throws keyword is used?
Locked. Enroll to open this question.
Question 54
Which are the two subclasses under Exception class?
Locked. Enroll to open this question.
Question 55
Explain Runtime Exceptions?
Locked. Enroll to open this question.
Question 56
What do you mean by Checked Exceptions?
Locked. Enroll to open this question.
Question 57
What is an Exception in Java?
Locked. Enroll to open this question.
Question 58
How Java Handles Exceptions
Locked. Enroll to open this question.
Question 59
What type of exceptions must be explicitly declared in a throws clause of a method?
Locked. Enroll to open this question.
Question 60
The finally block is the last bit of code executed before your program ends. True or False? Explain.
Locked. Enroll to open this question.
Question 61
What is wrong with this fragment?
Locked. Enroll to open this question.
Question 62
Why do you need multiple catch handlers?
Locked. Enroll to open this question.
Question 63
Advantages of Exception Handling
Locked. Enroll to open this question.
Question 64
What are the advantages of exception handling?
Locked. Enroll to open this question.
Question 65
What is the function of the catch block in exception handling? Where does it appear in a program?…
Locked. Enroll to open this question.
Question 66
When is Exception Handling required?
Locked. Enroll to open this question.
Question 67
What are the types of program errors?
Locked. Enroll to open this question.
Question 68
Example: OutOfMemoryError
Locked. Enroll to open this question.
Question 69
Example: StackOverflowError
Locked. Enroll to open this question.
Question 70
Example: NumberFormatException
Locked. Enroll to open this question.
Question 71
Example: ArrayIndexOutOfBoundsException
Locked. Enroll to open this question.
Question 72
Example: NullPointerException
Locked. Enroll to open this question.
Question 73
Example: ArithmeticException
Locked. Enroll to open this question.
Question 74
Example: IOException
Locked. Enroll to open this question.
Question 75
Types of Exceptions
Locked. Enroll to open this question.
Question 76
What is an Exception?
Locked. Enroll to open this question.
Get Java Fundamentals: Building Strong Foundations updates by email
Short, practical lessons and course updates from Rumman Ansari. No spam.