File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
Consider Paul's rocket mass heater.
 
subject: overriding methods: doubt
 
Similar Threads
overiding method
Regarding Overiding
Overiding
Help on overiding
Overiding and Exceptions