• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

question about exceptions

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for the following code, why when run dosen't print e.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mohamed hamdy:
for the following code, why when run dosen't print e.


Because the test method in the class Sub doesn't thrown an exception. In fact, it doesn't do anything. When overriding a method in a parent class, as is done in this case, the overriding method can throw any subset of checked exceptions that the parent method throws - including the empty set. That's the case here. The key is to realize that the test method being invoked is the one within the Sub class, not the one within the Exc class.
I hope that answers your question.
Corey
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic