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 Exception in Inheritance (overrridding) 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 "Exception in Inheritance (overrridding)" Watch "Exception in Inheritance (overrridding)" New topic
Author

Exception in Inheritance (overrridding)

Satyajit Bhadange
Ranch Hand

Joined: May 13, 2010
Posts: 104
hi

when we overrride method and if method we are overrriding throws exception but overridden method doesnt do the same java prog compiles but if case is exact opposite of mention then compiler doesnt allow me to compile my java prog...


Please ans with example which would be more clearer.


Thanks
user101
Problems And Solutions - Algorithms
Sona Patel
Ranch Hand

Joined: Mar 30, 2009
Posts: 75
refer this for clarity...
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Consider this:

1. Class A implements foo()
2. Class B extends A, overrides foo() and thows IOException
3. You create an instance of B and assign it to a reference variable of type A.
4. You call the foo() method.

The compiler would not force you to catch IOException, which is a checked exception, because it doesn't know you actually have an instance of B. This would be bad.
Satyajit Bhadange
Ranch Hand

Joined: May 13, 2010
Posts: 104
thanks..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in Inheritance (overrridding)
 
Similar Threads
Running C++ exe files
Calling DOS CLS (clear screen) in Java ?
Object Serialization like
wait(),notify()&notifyAll() of Object
Problem in Exception Handling??