String label?
posted 23 years ago
Ans : It will print Hello twice.
Fine I agree with the output.But I just want to check whether my thinking is the same as yours.
According to me, i<10 and i++ will take the value of i to 9
Similarly j<10 and j++ will take the value of j to 9
then finally it checks(i+j >10) i.e 9+9 >10 ; hence it breaks the string and prints" hello"
but the ansswer says the output is being printed twice..
Still confused??
Sonir
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Ans : It will print Hello twice.
Fine I agree with the output.But I just want to check whether my thinking is the same as yours.
According to me, i<10 and i++ will take the value of i to 9
Similarly j<10 and j++ will take the value of j to 9
then finally it checks(i+j >10) i.e 9+9 >10 ; hence it breaks the string and prints" hello"
but the ansswer says the output is being printed twice..
Still confused??
Sonir
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi Sonir,
The value of i will not go upto 9,
Case 1 : When value of i is 0 then the sum of i+j will not increase 10 as the max value of j is 9.
o/p - a hello will be printed
Case 2 : In this case also when the value is 1
o/p - a hello will be printed
Case 3 : In this iteration the value of i is 2
so the sum of i+j is more than 11, and that is the terminating condition.
HTH
Nisheeth
The value of i will not go upto 9,
Case 1 : When value of i is 0 then the sum of i+j will not increase 10 as the max value of j is 9.
o/p - a hello will be printed
Case 2 : In this case also when the value is 1
o/p - a hello will be printed
Case 3 : In this iteration the value of i is 2
so the sum of i+j is more than 11, and that is the terminating condition.
HTH
Nisheeth
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Could someone explain this line:
And this line:
I've never seen
String : for...
or
break String.
Thanks,
--Chris
[ January 10, 2002: Message edited by: Chris Graham ]
And this line:
I've never seen
String : for...
or
break String.
Thanks,
--Chris
[ January 10, 2002: Message edited by: Chris Graham ]
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
That is also a question that I have but never took the time to find out about. Does Java use labels like C/C++? What about goto?
My final question, do labels show up on the exam?
Thanks,
My final question, do labels show up on the exam?
Thanks,
Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
posted 23 years ago
Although goto is a reserved keyword in Java, it is not used.
Corey
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What about goto?
Although goto is a reserved keyword in Java, it is not used.
Corey
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I'm rusty on my C/C++ so I don't know if their use in java is "like them." But java does use labels; the syntax is an identifier, followed by a colon, followed by a statement/statement block.
The label really only allows you to do two things with it, break out of it, or continue in it. You see labels mainly used in loop structures.
As for goto, what's that???
In java, goto is a reserved word. The language imlementors decided to make it reserved as a convenience for java compilers that might end up parsing C code and be able to "identify" that word, because it can be common in C/C++ source code. But the java language itself does not implement the use of goto.
So for the test, just remember that goto is a reserved word, but it's not used.
Rob
[ January 10, 2002: Message edited by: Rob Ross ]
The label really only allows you to do two things with it, break out of it, or continue in it. You see labels mainly used in loop structures.
As for goto, what's that???
In java, goto is a reserved word. The language imlementors decided to make it reserved as a convenience for java compilers that might end up parsing C code and be able to "identify" that word, because it can be common in C/C++ source code. But the java language itself does not implement the use of goto.
So for the test, just remember that goto is a reserved word, but it's not used.
Rob
[ January 10, 2002: Message edited by: Rob Ross ]
Rob
SCJP 1.4
| It would give a normal human mental abilities to rival mine. To think it is just a tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |







