Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes exception handling?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "exception handling??" Watch "exception handling??" New topic
Author

exception handling??

srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252


here i thought that A and c are printed...
but not its compile error...
exception java.io.IOException is never thrown in the corresponding try block ...
i didnt get it ...
instead of java.io.IOException i kept java.lang.Exception it worked fine...
whats the concept behind this???


Thanks & Regards<br /> <br />-Srikanth
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
IOException is a checked exception you are trying to catch it but it's not thrown so the compiler is smart and throws a compile time error. But this is not the case with the class Exception , even though it's not thrown explicitly , there are possibility of getting runtime exceptions like NullPointer hence it compiles
[ October 13, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exception handling??