Exceptions in Java: Definition & Example


Choose an answer and hit 'next'. You will receive your score and answers at the end.

question 1 of 3

Which of the following code samples will create an exception in Java?

Create Your Account To Take This Quiz

As a member, you'll also get unlimited access to over 79,000 lessons in math, English, science, history, and more. Plus, get practice tests, quizzes, and personalized coaching to help you succeed.

Try it risk-free
Try it risk-free for 30 days. Cancel anytime
Already registered? Log in here for access

1. Examine the following code. What will happen if the file myfile.txt is not found?

2. Java keeps a list of exceptions and will know what exception has occurred. Where are these stored?

Create your account to access this entire worksheet
A Premium account gives you access to all lesson, practice exams, quizzes & worksheets
Access to all video lessons
Quizzes, practice exams & worksheets
Certificate of Completion
Access to instructors
Create an account to get started Create Account

About This Quiz & Worksheet

What are the different exceptions in Java? See what you know about them and go over some examples by completing the quiz and worksheet.

Quiz & Worksheet Goals

You can see just how much you know about:

  • The consequence of the file myfile.txt not being found
  • A code that catches an exception and performs another code
  • Code samples that create an exception in Java
  • Where exceptions are stored

Skills Practiced

  • Reading comprehension - ensure that you draw the most important information from the lesson on exceptions in Java
  • Information recall - access the knowledge you have gained about an exception that occurs if you try to reference an index of an array that doesn't exist
  • Interpreting information - verify that you can read information about where exceptions are stored and interpret it correctly

Additional Learning

Exceptions in Java: Definition & Example is a lesson you can use anytime you want to cover more about exceptions. Some objectives you can cover include:

  • Define exception in Java
  • Compare and contrast the different exception types
  • Review Java classes