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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dead Code" Watch "Dead Code" New topic

Dead Code

Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi, This is from examLab. Why am I getting Dead Code warning instead of compiler error.
Trishul P Mukherjee

Joined: Oct 29, 2007
Posts: 17

Please correct me if I'm wrong but I'm not sure if this code is giving any error.
Tested with Eclipse 3.4 and JDK 1.6.0_17 - the compiler isn't showing any errors. Also, the output is 3 - as expected.

OCPJP 6 (83%)
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi Trishul, As mentioned there are no errors. It is all about warnings. My question is, Why warning is coming instead of an error. I am expecting error at Line 23 but I am getting only warning.
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

IMHO This Thread will be helpfull for you.

SCJP 6 | FB : Java Certifications-Help. | India Against Corruption
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3011

"Phunsuk Wangdu", please check your private messages for an important administrative matter.

Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
I agree. Here's the link:
subject: Dead Code
Similar Threads
Exception Doubt
Required more explantion on exmaple given in Thread.
No Unreachable error ?
Why not "Unreachable Code" Error..?
examlab(question-53)-unreachable statement NAO?