This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confused" Watch "confused" New topic
Author

confused

kavita s. kumar
Greenhorn

Joined: Oct 26, 2001
Posts: 16
Hi
my question is
overridden method must not throw any exception which is not
thrown by overridden method
is it true..
i feel overriden method should not throw any checked exception which is not thrown by overridden method
i am right
thanks in advance
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
Originally posted by kavita s. kumar:
Hi
my question is
overridden method must not throw any exception which is not
thrown by overridden method
is it true..
i feel overriden method should not throw any checked exception which is not thrown by overridden method
i am right
thanks in advance


Kavitha
If you override a method
The overriding method must throw nuthing/same-exceptions/subclass of the exceptions thrown by the original method
HIH
Ragu
Cristian Negresco
Ranch Hand

Joined: Sep 15, 2001
Posts: 182
Hi Kavita,
I think you are right:

class A {
void m() {
System.out.println("A");
}
}
public class E extends A {
void m() throws ArrayIndexOutOfBoundsException {
System.out.println("B");
}
}
The class E compiles without problem.
So, the overriding method can throw any "unchecked" exceptions. Perhaps this is also one reason for which the some exceptions are "checked", becouse the compiler "checks" them.
..Cristian
 
Consider Paul's rocket mass heater.
 
subject: confused
 
Similar Threads
Exception
some doubts
Exception
K&S Chapter 5 q-3
Questions from mock Exam !!!