If a superclass method does not throw an exception, can the overridden method in the subclass throw an exception?

  • No, it cannot throw any exception
  • No, it cannot throw any exception
  • Yes, it can throw any exception
  • Yes, it can throw any exception
In Java, if a superclass method does not declare any exceptions, the overridden method in the subclass cannot throw checked exceptions that are broader in scope than those of the superclass method. This rule is in place to ensure that the subclass does not introduce unexpected exceptions.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *