This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes regarding Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regarding Exceptions" Watch "regarding Exceptions" New topic
Author

regarding Exceptions

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
A subclass cannot throw more checked exceptions that its superclass,why??
Any performance issues or what is the reason??
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I posted something on this HERE the other day. See if that helps.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
Hi Stan,
Thanks for providing the link.In this link i have one doubt.



And what if somebody passed an instance of B into my method? I'd be totally unprepared to handle a SQLException because A never told me it might happen.



If something happens in class B,B should take care of it.Why should it rely on class A.
Please clear the doubt.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3431
    
  12
If B takes care of the SQLException, then there is no problem, because the method will no longer throw a SQLException. Stan's example was showing the problem with the method throwing a broader exception than declared in the parent class.
[ August 01, 2007: Message edited by: Joanne Neal ]

Joanne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding Exceptions
 
Similar Threads
writing from a jar
while loop
executeBatch() not executing
my query is successfully running in database but it is returning empty resultset in my java program
Questions from mock Exam !!!