File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding and Exceptions - Examlab question

 
Larry Olson
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Time for me to ask a question

Here is a question from Examlab Test # 3



My question:

Even though class UDI's buildNow() method doesn't explicitly declare that it throws IOException, is it implicit that it throws an IOException, since UDI implements Buildable and Buildable's buildNow() method declares to throw an IOException ?

I do understand the rules about overriding and exceptions i.e. The overriding method can't throw more or broader exceptions than the overridden method. But the question is if the overriding method doesn't declare to throw any exceptions at all, does it still implicitly throw all the exceptions that is declared in the overridden method?

Thanks.
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the question is if the overriding method doesn't declare to throw any exceptions at all, does it still implicitly throw all the exceptions that is declared in the overridden method?

No, since the buildNow method in UDI doesn't explicitly declare IOException, so it cannot throw that exception, there is no implicit inheritance of thrown exceptions...
 
Larry Olson
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is no implicit inheritance of thrown exceptions...


Thanks. You put it very clearly. I have been confused about this all along.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic