Java SE 13: Try-with-resources & Custom Exceptions


Overview/Description
Expected Duration
Lesson Objectives
Course Number
Expertise Level



Overview/Description

In this course, you will learn about the correct use of the throws clause, Java's relatively new try-with-resources construct, and the use of custom exceptions. Explore how to correctly use the throws clause while defining method signatures and implementing exception handling in a chain of methods that sequentially call each other. You will learn to ensure that resources are automatically closed, relying on language support, using the try-with-resources construct; and recognize the precise semantics of this construct in Java. This leads to throwing an object of a built-in exception type to respond to an unexpected situation in a program, and differentiating between the semantics of throwing runtime exceptions versus checked exceptions. The correct way to invoke a method that throws an exception of a checked exception type will be examined, along with how to correctly declare or handle exceptions in a chain of functions, each of which throws different types of exceptions. Finally, participants will explore the use of custom exceptions, defining their own exception classes, and then throwing exceptions that belong to those classes.



Expected Duration (hours)
1.5

Lesson Objectives

Java SE 13: Try-with-resources & Custom Exceptions

  • discover the key concepts covered in this course
  • correctly use the throws clause while defining method signatures
  • implement exception handling in a chain of methods that sequentially call each other
  • ensure that resources are automatically closed, relying on language support, using the try-with-resources construct
  • recognize the precise semantics of the try-with-resources construct in Java
  • throw an object of a built-in exception type in order to respond to an unexpected situation in a program
  • differentiate between the semantics of throwing runtime exceptions vs. throwing checked exceptions
  • correctly invoke a method that throws an exception of a checked exception type
  • correctly declare or handle exceptions in a chain of functions, each of which throws different types of exceptions
  • create a custom exception object by extending the base class Exception, and throw an instance of this exception from your code
  • instantiate and throw custom exception objects of both checked and unchecked exception types
  • summarize the key concepts covered in this course
  • Course Number:
    it_jdcojdj_07_enus

    Expertise Level
    Intermediate