Question d’entretien chez BT Group

Parent Class method throws illegalMonitorStateExcpetion,Can the child class Overrided method throws RuntimeException?

Réponses aux questions d'entretien

Utilisateur anonyme

2 janv. 2016

No,Child class method can throw child Exceptions of IllegalMonitorStateException Not its Parent.

4

Utilisateur anonyme

25 févr. 2016

The overriding method can throw any unchecked (runtime) exception, regardless of whether the overridden method declares the exception or not.

Utilisateur anonyme

6 janv. 2016

Yes, It can throw a RuntimeException. RuntimeException and It's childs are Unchecked Exceptions. When a parent class throws a checked exception that means overridden method, overriding method in child class it's optional to throw checked exception. If overriding method throws a checked exception that should be same as overridden or it's child. In above question it can throw a unchecked exception.

4