aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP Brainteaser (12) 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 "SCJP Brainteaser (12)" Watch "SCJP Brainteaser (12)" New topic
Author

SCJP Brainteaser (12)

Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

What this code will do..

Will it compile or not.



Enjoy Brainteaser.

Will come with some more


The Best way to predict your future is to create it - Every great individual common man
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

Hi Sharma Ji,

The above code won't compile as you are using a label http: not for a loop but for a statement.

Thanks.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Asha Lilliete
Greenhorn

Joined: Jun 28, 2006
Posts: 6
The given code is getting compiled
The thing is the label cannot be used.
Saurabh Vyas
Ranch Hand

Joined: Sep 02, 2003
Posts: 72
I think the code should compile as it is a valid label and label can be used anywhere.

Good question. a real googly
[ November 14, 2006: Message edited by: Saurabh Vyas ]
rajanikar reddy
Greenhorn

Joined: Oct 15, 2006
Posts: 1
I think code will compile
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by rajanikar reddy:
I think code will compile


Really !!!

Could you also pour your thoughts behind this reason.
Rajesh Kadle
Greenhorn

Joined: Sep 06, 2004
Posts: 26
Code will compile.

http : is treaded as label

www.google.com; is commented out in //www.google.com;


-Raj
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Rajesh Kadle:
Code will compile.

http : is treaded as label

www.google.com; is commented out in //www.google.com;


Then this means this code will also compile




What are your thoughts now.

Now you can use your PC to check what are the things which are really going on.
Saurabh Vyas
Ranch Hand

Joined: Sep 02, 2003
Posts: 72


This code will not compile as there is no valid java statement after the label.
There should be atleast one valid java statement after the label which has semi-colon at the end.
Harshad Khasnis
Ranch Hand

Joined: Jun 06, 2006
Posts: 48

[/CODE]

No Sharma Ji that certainly not going to compile, but yes this one sure will compile,


[ November 15, 2006: Message edited by: Harshad Khasnis ]
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Saurabh Vyas:

This code will not compile as there is no valid java statement after the label.
There should be atleast one valid java statement after the label which has semi-colon at the end.


here we end up by this thread. Very good Catch Saurabh .

That was the only point in this question.

Now Enjoy other BrainTeasers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCJP Brainteaser (12)