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 Programmer Certification (SCJP/OCPJP) and the fly likes JQ+: Question ID :960680824810 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JQ+: Question ID :960680824810" Watch "JQ+: Question ID :960680824810" New topic
Author

JQ+: Question ID :960680824810

Rodney Woodruff
Ranch Hand

Joined: Dec 04, 2001
Posts: 80
Question ID :960680824810
An overriding method can declare ArithmaticException in it's throws clause even if the overridden method does not have any throws clause.
True or False.
I chose "False". I must admit, wording is really confusing. Can someone clarify this for me? Thanks alot.


Hope This Helps
Steven Wong
Ranch Hand

Joined: Mar 07, 2002
Posts: 295

Question ID :960680824810
An overriding method can declare ArithmaticException in it's throws clause even if the overridden method does not have any throws clause.
True or False.

Hi, the answer is True. Because the ArithmeticException is an unchecked exception(runtime exception) and thus does not need to be caught or handled.
Clement


best regards,<br />Steven<br />SCJP, SCEA
Rodney Woodruff
Ranch Hand

Joined: Dec 04, 2001
Posts: 80
Thanks Clement! The wording was really confusing. I get it now. I just wish that they could have worded it a little better.
Gautam Sewani
Ranch Hand

Joined: Apr 19, 2002
Posts: 93
Does that mean that there are no restrictions on an overriding method in the throws clause incase of unchecked exceptions?
If the overriden method does not specify any unchecked exceptions,still the overriding method can specify them in its throws clause.
Is this right?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
There are no rules based on unchecked exceptions. That's why they're called "unchecked" exceptions. In fact, even if a method declares that it throws an unchecked exception, the invoking method need not handle it.
This code compiles and runs fine:

Corey


SCJP Tipline, etc.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JQ+: Question ID :960680824810
 
Similar Threads
JQPlus Q. 1.
HELP: doPost without throw
Mock exam question (exceptions)
Which Exceptions a method can throw?
abstract methods