aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding and Exceptions - Examlab question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding and Exceptions - Examlab question" Watch "Overriding and Exceptions - Examlab question" New topic
Author

Overriding and Exceptions - Examlab question

Larry Olson
Ranch Hand

Joined: Feb 03, 2009
Posts: 142
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

Joined: Aug 03, 2008
Posts: 9321
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Larry Olson
Ranch Hand

Joined: Feb 03, 2009
Posts: 142
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
 
subject: Overriding and Exceptions - Examlab question