Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
12.14. Common Exceptions in Java
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
4 cards from this lesson. Good the night before a test.
Try these first
- 1.
What type of exception is thrown when a program tries to divide by zero?
Hint
Think about illegal arithmetic operations.
- 2.
What is the term for an exception indicating a file doesn't exist?
Hint
This is a checked exception.
- 3.
What type of exception occurs when you divide by zero in Java?
- FileNotFoundException
- ArithmeticException
- NullPointerException
Hint
Connect your answer back to illegal arithmetic operations.
- 4.
True or False: A FileNotFoundException is an example of an unchecked exception.
- True
- False
Hint
Remember the definitions of checked and unchecked exceptions.
- 5.
Write a Java program that handles multiple exceptions, including IOException and ArithmeticException when reading user input.
Hint
Use try-catch to manage user input errors.
- 6.
Consider a scenario where a program attempts to read a file that might not exist You need to design exception handling for both cases: file exists and does not exist.
Hint
Think about how to handle the absence of a file gracefully.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting