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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "exceptions" Watch "exceptions" New topic
Author

exceptions

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521


i get a compiler here that try block never throws an ioexception but it were

then there is no error why?


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

yes because IOException is a checked exception.
you must do such operation into try block which throw ioexception or throw new IOException () explicitly.


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
IOEXception is a subclass of Exception right....how is exception not a check exception when it includes both checked and unchecked exceptions
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Minhaj kaimkhani wrote:yes because IOException is a checked exception.
you must do such operation into try block which throw ioexception or throw new IOException () explicitly.


what Minhaj says is true.

Raju Champaklal wrote: IOEXception is a subclass of Exception right....how is exception not a check exception when it includes both checked and unchecked exceptions

because it can catch a runtime exception also about which compiler doesn't know anything so it will not give any error and hence Exception can never be checked exception.


SCJP 1.6 96%
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

the classes those directly extends java.lang.Exception are checked exception for example
java.io.IOException

and the class those indirectly extends are un-checked exception for example

"java.lang.NullPointerException" <= its an unchecked exception

see the difference into hierarchy

java.lang.Object
extended byjava.lang.Throwable
extended byjava.lang.Exception
extended byjava.lang.RuntimeException
extended byjava.lang.NullPointerException
and

java.lang.Object
extended byjava.lang.Throwable
extended byjava.lang.Exception
extended byjava.io.IOException
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

There have been recent discussions in the past on this topic like this or this...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exceptions