• 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

JQPlus Q. 1.

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question ID :954959342609
Which of the following exceptions can be declared in the throws clause of a method overriding the method:
public void perform_work( ) throws IOException {...}
One of the options is NullPointerException.
My question is can an overridden method throw an ecxeption(obviosly not a subclass of exception thrown in overriding method) which is not thrown in overriding method?? Or following is a right overriden method??
public void perform_work() throws IOException, NullPointerException{....}
Tanveer
 
Enthuware Software Support
Posts: 4810
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember, NPE is a runtime exception!
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

Try out the world's only WebCompiler!
www.jdiscuss.com
 
Tanveer Mehmood
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anil, should I conclude that overriden method can throw any unchecked exception(not thrown in overriding method) or its something else you wanted to cite in your lengthy explaination. Anyhow, thx for ur reply...
Tanveer
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tanveer,
Yes, your last statement is correct. An overridden method can throw any unchecked exception it wants to without regard to the overridden method signature.
Regards,
Manfred.
 
reply
    Bookmark Topic Watch Topic
  • New Topic