aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes overriding methods: doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "overriding methods: doubt" Watch "overriding methods: doubt" New topic
Author

overriding methods: doubt

rijagu chan
Greenhorn

Joined: Apr 10, 2000
Posts: 7
One of the answers is the overiding method must not throw any exceptions that may not be thrown by the overridden method.
My question is what about a RuntimeException. What if I throw an ArithmeticException explicitly only in the overiding method.
void overriddenMethod() { }
void overridingMethod() throws ArithmeticException { }
Uvnik Gupta
Ranch Hand

Joined: Jul 24, 2000
Posts: 32
The statement is a bit ambiguous. If it means only checked exceptions then it's correct but if it means any kind of exception, it's wrong.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
A RuntimeException can be thrown by the overridden method or the overriding method. The statement only talks about exceptions that can not be thrown by the overridden class, and so it has nothing to with RuntimeExceptions (or Errors for that matter). The statement is definitely true.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: overriding methods: doubt