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

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions" Watch "Exceptions" New topic


Trader Joey
Ranch Hand

Joined: May 11, 2000
Posts: 33
1. all exceptions are subclasses of .Throwable class.
2. Exceptions of the Exception subclass may be handled in a try/catch block.
3. Exceptions of the Error subclass should never be handled.
4. if a method does not handle an exception it must be declared in the throws clause. the exception declared in the throws clause may be any exception which is a subclass of Exception but not of RuntimeException.
Are all the points mentioned above correct ???
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
IMO, all the points are valid except 2nd.
2nd should be "Exceptions of Exceptions can be handled in try/catch block except 'Runtime Exceptions'.
Please correct me if I'm wrong.
Ranch Hand

Joined: Apr 24, 2000
Posts: 44
Exception subclass only contains checked exceptions, unincluding Runtime exceptions. so 2) should be true, right?
Ranch Hand

Joined: May 08, 2000
Posts: 76
hi nikhil,
Runtime exceptions can also be put in the throws clause, but it is not of any use, since they are implicitly included!! So, you won't get any compile time/ runtime error, even if you put it in the throws clause.
I tried this program:

It works the same way, even if you remove the throws clause of the divide method definition.
Hope it's of some use
Have you tried LearnNowOnline?
subject: Exceptions