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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Unreachable statements" Watch "Unreachable statements" New topic
Author

Unreachable statements

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442

The above code compiles & runs fine.
Shouldn't th above code give complier error that "Unreachable statement"?Co line 1 is never reached What are the scenarios when compiler throws unreachable statement error?Are these kind of questions ,where compiler gives error that"Unreachable statement" going to appear in the exam?
thanks
Veena


SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
Method m1() might throw an exception that would halt the program as opposed to having a straight statement like throw new Exception(); A call to a method throwing an exception shouldn't make a statement immediately after it unreachable. Don't forget, m1() can be overridden not to throw any exception.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unreachable statements
 
Similar Threads
An Exception question in Dan's mock exam
Q5 from Dan's top exam (2nd)
Question from Dan Mock Exam
danchisholm.net exam3 Question 6
Exception logic.