• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Overriding and Exceptions - Examlab question

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic