[11/13] Java Foundations Certification: Exception Handling

Share on facebook
Share on twitter
Share on linkedin
Build a strong foundation of knowledge in Java programming! Learn all about handling exceptions in your code!

In the current lesson, we take a close look at exception handling and why it’s important in software engineering.

What are exceptions? We’ve all seen one, there is no way to write completely bug-free code. In short an exception is a problem that arises during the execution of the program

Exceptions simplify code construction and maintenance and allow problematic situations to be processed at multiple levels.

In Java exceptions are objects. The base for all exceptions is the Throwable class – it contains information about the cause of the exception, its description, and the stack trace.

There are two types of exceptionschecked (also known as compile-time exceptions), and unchecked (also known as runtime exceptions).

Exceptions can be handled by the try-catch construction. The try-finally block is also used, especially when we want to ensure the execution of a given block of code. 

To raise an exception, we use the throw keyword. When an exception is thrown the program execution stops, and the execution travels over the stack until a matching catch block is reached to handle it. 

In this lesson you will find many helpful examples and exercises, so make sure to practice what you’ve learned! That’s the only way to grasp the concept at hand.

Do you have questions? We’re always here to help! Join our Facebook group and ask away!

If you are new to programming, make sure to watch the Free Full Java Basics course first, as it is a necessary prerequisite to this one. It explains the topics in a lot more detail, as this video aims to revise them and get to more complex topics after that.
This course is also perfect for people who have some background in programming with a different language and would like to pick up on Java.

Lesson Topics

This video covers the following topics:

1. What are Exceptions?

  • The Exception class 
  • Types of exceptions and their hierarchy

2. Handling Exceptions

3. Raising (throwing) Exceptions

4. Best Practices

5. Creating Custom Exceptions

Remember that coding is a skill, which should be practiced. To learn to code, you should write code, every day, for a long time. Watching tutorials is not enough. You should code! Now it’s your turn. Do your exercises!

Register now and take your free resources right away! You will get access to the 55+ fully automated exercises which will sharpen your coding skills. You will become a member of the SoftUni Global Community and we will provide you the opportunity to communicate with other students and mentors and get help for FREE.

2 thoughts on “[11/13] Java Foundations Certification: Exception Handling”

    1. Hello,
      You can use the following code to calculate sin(180):
      double angle = 180;
      double sin180 = Math.sin(Math.toRadians(angle));

      Notice we use Math.round() at the end. Otherwise, you will get a number very close to 0, but not exactly zero.
      We hope that was helpful. We’re available for any questions to follow.
      Have a great day!

Leave a Comment

Scroll to Top

Sign in

Don’t have an account? Register with us to join the community.