1/20
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What happens when a program encounters a runtime error?
The program terminates abnormally.
What is the purpose of exception handling?
To allow a program to continue running or terminate gracefully after encountering an error.
What are the two main types of exceptions in Java?
Checked exceptions and unchecked exceptions.
What is the role of the 'throws' keyword in a method declaration?
It indicates the types of checked exceptions that a method might throw.
What is a try-catch block used for?
To handle exceptions that may occur during the execution of statements.
What is the purpose of the finally clause in exception handling?
To execute code that must run regardless of whether an exception occurred or not.
When should you throw an exception?
When an error occurs in a method and you want it to be processed by its caller.
What is a custom exception class?
A class that extends Exception or a subclass of Exception to define specific error conditions.
What is the difference between checked and unchecked exceptions?
Checked exceptions must be declared or handled, while unchecked exceptions do not require explicit handling.
What is the purpose of the catch block?
To define how to handle specific exceptions that are thrown.
What does the 'throw' keyword do?
It is used to throw an exception object.
What is the role of the 'catch' keyword?
It is used to catch exceptions thrown by the try block.
What is the purpose of the 'throw new IllegalArgumentException' statement?
To throw an exception when an invalid argument is passed to a method.
How can you handle multiple exceptions in a single try block?
By using multiple catch blocks, each handling a different exception type.
What is a runtime exception?
An error that occurs while the program is running (after compiling)
When does an ArithmeticException occur?
when an illegal math operation happens (division by zero etc.)
When does an ArrayIndexOutOfBoundException occur?
when accessing an array with an invalid index
when does a StringIndexOutOfBoundsException occur?
when accessing a string with an invalid index
when does a ClassCastException occur?
when trying to cast an object to an incompatible type
when does a NullPointerException occur?
when trying to use an object that is null
when does a NumberFormatException occur?
when converting a string to a number fails