Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 17
Output : A curiosity compiler OK (?) Reason : because of // in http://, www.google.com works as a comment in the entire program. Allowing both the outputs to be printed....(?)
24th May 2017, 3:32 AM
Dev
Dev - avatar
+ 17
There's a point I got : What's the answer if we change http: to any other name like dhhj: ? Would it work?
24th May 2017, 4:03 AM
Dev
Dev - avatar
+ 16
I'm going for d too because the "jumping goto statement thing" is there but never "called" so I reckon it can be ignored in this case. (I know the //www.google.com bit is definitely ignored because it's a comment)
24th May 2017, 1:21 AM
Jafca
Jafca - avatar
+ 16
and what if we don't put a : after http?
24th May 2017, 4:05 AM
Dev
Dev - avatar
+ 16
So, now we're gonna report it to them? 😂 Add label: to the Java course...
24th May 2017, 4:15 AM
Dev
Dev - avatar
+ 14
Adding onto what @Sachin and @Steven have said, the (word): is like a goto statement except that you don't go to it, you go to the line after it (if that makes sense)
23rd May 2017, 10:59 PM
Jafca
Jafca - avatar
+ 10
http: in here looks like goto statement we use in C, if there exists a goto statement in java also, then the code will run perfectly, else syntax error (Which I thought at first sight). But in java, break is used in place of goto. Check- http://www.aboutcodes.com/2012/07/goto-statement-in-java-with-example.html?m=1
23rd May 2017, 7:48 PM
Sachin Artani
Sachin Artani - avatar
+ 9
the answer is the option d because the http //www.Google.com is treated as comment and it is not executed and system prints the output as option d
24th May 2017, 2:05 AM
MsJ
MsJ - avatar
+ 7
@Ace, 😂😂 as it is clearly visible that www.google.com is a single line comment followed by // So it is ignored, now it is only http: which is also ignored but it's not a comment. Now, tell us what is the reason?
24th May 2017, 4:00 AM
Sachin Artani
Sachin Artani - avatar
+ 7
Sure it will, because http is just a name
24th May 2017, 4:04 AM
Sachin Artani
Sachin Artani - avatar
+ 7
@Ace, I gave the same answer, I just didn't specified the word label. https://stackoverflow.com/questions/2399590/java-what-does-the-colon-operator-do
24th May 2017, 4:10 AM
Sachin Artani
Sachin Artani - avatar
+ 6
Java thinks http: might be a continue label for an iterative loop. However Java can find no loop referencing the label and so ignores http:. http://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html
24th May 2017, 3:57 AM
Steven Schneider
Steven Schneider - avatar
+ 6
Error, saying what is http??
24th May 2017, 4:06 AM
Sachin Artani
Sachin Artani - avatar
+ 6
@Ace, Ooo, ok I'll not forget to remember the terms by now 😊😊
24th May 2017, 4:15 AM
Sachin Artani
Sachin Artani - avatar
+ 6
Yes, self education does tend to leave holes in one's understanding that might not be rectified without a formal education to go with it.
24th May 2017, 4:15 AM
Steven Schneider
Steven Schneider - avatar
+ 6
That's too bad @Ace. We need questions like these in our tutorials to stretch our minds. Education mandated by popularity has some obvious drawbacks.
24th May 2017, 4:20 AM
Steven Schneider
Steven Schneider - avatar
+ 5
Well, I'm more confused than ever but, if the compiler ignores the line starting with http and goes to the next line, then my guess is d. Of course I might be completely wrong and I suspect I probably am.
24th May 2017, 1:05 AM
Steven Schneider
Steven Schneider - avatar
+ 5
@Ace, it is not in sololearn course?
24th May 2017, 4:11 AM
Sachin Artani
Sachin Artani - avatar
+ 4
b. error. http is not a command. www.google.com gets commented out.
23rd May 2017, 6:59 PM
Randy Suwandee
Randy Suwandee - avatar
+ 4
I also go with the answer d
24th May 2017, 3:45 AM
Sumita
Sumita - avatar