Java Exception Handling - 1

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Dthakker11
D
Dthakker11
Community Contributor
Quizzes Created: 3 | Total Attempts: 2,301
| Attempts: 1,230 | Questions: 6
Please wait...
Question 1 / 6
0 %
0/100
Score 0/100
1. If a statement tries to divide by zero which exception is thrown?

Explanation

When a statement tries to divide by zero, the exception thrown is ArithmeticException. This exception occurs when an arithmetic operation in Java has an illegal or undefined result, such as division by zero. In this case, since the statement is attempting to divide by zero, it will throw an ArithmeticException.

Submit
Please wait...
About This Quiz
Java Exception Handling - 1 - Quiz

Explore Java Exception Handling in this quiz. It covers fundamental concepts like Throwable, Checked Exceptions, ArithmeticException, and system errors. Ideal for learners seeking to enhance their Java error handling skills.

Personalize your quiz and earn a certificate with your name on it!
2. Which of the following is true regarding try blocks in Java language?

Explanation

Try blocks must have at least one corresponding catch block in Java language because try blocks are used to enclose the code that may throw an exception, and the catch block is used to handle the exception that is thrown. Without a catch block, the code would not be able to handle the exception and would result in a compilation error. Therefore, it is necessary to have a catch block for every try block to handle the potential exceptions.

Submit
3. What is the base class for Error and Exception in Java?

Explanation

In the hierarchy of Exceptions, it all starts with Object class (which is a superclass of all classes), and the follows Throwable class.

Submit
4. I will cause a complier error if you did not declare/handle me in your program. I am :

Explanation

Checked Exception - the name itself suggests it is checked by the Java compiler!! You can not move ahead with execution of your program if you have these exceptions in your coding.

Submit
5. An instance of _________ describes system errors. If this type of error occurs, there is little you can do beyond notifying the user and trying to terminate the program gracefully.

Explanation

An instance of "Error" describes system errors. If this type of error occurs, there is little you can do beyond notifying the user and trying to terminate the program gracefully. Errors are typically caused by serious problems that cannot be easily recovered from, such as out of memory errors or stack overflow errors. They are not meant to be caught and handled like exceptions, but rather indicate a severe problem that may require intervention from the developer or system administrator.

Submit
6. Two classes of exceptions you should ideally deal in your program are:

Explanation

In Java, there are two main types of exceptions that should ideally be dealt with in a program: Checked Exceptions and Runtime Exceptions. Checked Exceptions are the exceptions that are checked at compile-time and are required to be handled or declared in the method signature. They are typically used to handle anticipated errors or exceptional conditions that can occur during the execution of a program. Runtime Exceptions, on the other hand, are not checked at compile-time and do not require explicit handling. They are usually caused by programming errors or unexpected conditions that may occur during the runtime of a program. Therefore, it is important to handle both types of exceptions to ensure proper error handling and program stability.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 15, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 15, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 30, 2018
    Quiz Created by
    Dthakker11
Cancel
  • All
    All (6)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
If a statement tries to divide by zero which exception is thrown?
Which of the following is true regarding try blocks in Java language?
What is the base class for Error and Exception in Java?
I will cause a complier error if you did not declare/handle me in your...
An instance of _________ describes system errors. If this type of...
Two classes of exceptions you should ideally deal in your program are:
Alert!

Advertisement