Java Fundamentals - Lesson 28 - Managing Exceptions

preview_player
Показать описание
Are you new to Java development? Do you want to know what to start with? This is a complete stream dedicated to you - the junior developer or future developer.

- Java OCP 11 certification
- Learn Java basics
- Find a junior java developer role

If your target is at least one of the above, then this lesson streaming is for you. Join!

Don't forget to follow me on Twitter @laurspilca or LinkedIn for more posts and discussions.

Рекомендации по теме
Комментарии
Автор

Thanks!. I have a question .Why we are able to throw runtime exception in the override method even though the overriden method doesn't throws any exception or only checked exceptions.

AliHassan-bzsk
Автор

Thanks! Just one thing really confuses me. If a method "throws" an exception which is redundant means it is not actually thrown from any where inside the method, why we are enforced by the compiler to treat it when we invoke that method even though in reality we didn't throw that exception in the method body ?

AliHassan-bzsk
Автор

Hi Laur! I have a question. In the code below, are we throwing RuntimeException in the method level because we want to have flexibility of having the RuntimeException in the classes that extend this interface. Such as in the overridden method you may or may not throw this RuntimeException? Is that the case? Are we doing this just for a specific method why not we are doing it in the class decleration? thank you!

package main;

import
import

public interface I1 {

void m() throws MyRuntimeException;
// sometimes you throw runtime exception for document purposes
}

Rocky_