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. Exception Handling
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 is an exception?
Hint
Think about what happens when there's an error.
- 2.
Mention one example of a checked exception.
Hint
It's related to handling files.
- 3.
What mechanism allows you to handle errors in Java?
- try-catch
- do-while
- for-each
Hint
Remember the keywords related to error handling.
- 4.
True or False: Checked exceptions are ignored at compile time.
- True
- False
Hint
Consider what checked exceptions require from the programmer.
- 5.
Write a Java program that demonstrates the use of checked and unchecked exceptions, handling each properly.
Hint
Focus on creating methods that throw both types and demonstrate proper handling.
- 6.
Create a custom exception class named AgeTooLowException and demonstrate how to throw this exception in a method.
Hint
Think about how to extend Exception and provide an appropriate message.
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
3 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
2 more questions 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