This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Exceptions and Overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exceptions and Overriding" Watch "Exceptions and Overriding" New topic
Author

Exceptions and Overriding

Naina Si
Ranch Hand

Joined: Nov 05, 2003
Posts: 134
Overriding methods can't be declared to throw checked exceptions other than those that were declared by the method in the super class,

How does that work for user defined exceptions?
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
I don't understand how the fact that it's a user-defined exception throws a wrench into the works. It's exactly the same. If want to override a method, you can't declare that your overridden version throws any exception types that are not assignable to one of the exception types declared to be thrown by the original method's definition. If you want to extend one of the exception types thrown by the original method (make a specific subclass of IOException for example), you can do that and throw one of those types.


James Carman, President<br />Carman Consulting, Inc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions and Overriding
 
Similar Threads
About exceptions in overriding & overloading
overriding rules
Exception
doubt in overridding
All the overriden equals!