This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions" Watch "Exceptions" New topic
Author

Exceptions

vinita Kh
Ranch Hand

Joined: Feb 19, 2002
Posts: 49
nebody plz explain the output of this code, why compile time error?

[ Added UBB [ CODE ] tags to add whitespace and improve readability ]
[ May 12, 2002: Message edited by: Jessica Sant ]
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
The following part of the code has trouble
static void throwMethod() {
System.out.println("Inside throwMethod.");
throw new IllegalAccessException("demo");
}
throwMethod actually throws exception. So, either the IllegalAccessException exception (or its superclass) should be cought or the method has to declare that it throws IllegalAccessException exception (or its super class).
try changing the method as
static void throwMethod()
throws IllegalAccessException
{
System.out.println("Inside throwMethod.");
throw new IllegalAccessException("demo");
}


ChintanRajyaguru.com
SOADevelopment.com - Coming soon!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions