SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Author @ http://www.ideasforideas.org/
Moody blogger who do not like to behave like target setting machines work.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:The loop has also finished so x will again be set to 0 and gc will be set to true.
When it's obvious that you have to do it, just do it without shattering your thoughts over different directions.
so the output would be "true 0"
SCJP 6.0 Passed | SCWCD Passed | PSM in progress...
Rajshekhar Paul wrote:But inside the first if block, x will be incremented. So, in the second if block, x will not be 0.
Kamil Wojcik wrote:I don't get that output, everytimes it's different answer. Is it possible to get such question on the exam? (I mean with random answers).
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:No that will not happen. The if condition will be false as gc will be false till now.
When it's obvious that you have to do it, just do it without shattering your thoughts over different directions.
A.true will never be output
B.true will be output at least once
C.if true and false are both output,their respective values for x can be the same.
D.if true and false are both output,their respective values for x can never be the same.
E.This code will not compile
F.A given value for x can never be output more than twice
When it's obvious that you have to do it, just do it without shattering your thoughts over different directions.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
When it's obvious that you have to do it, just do it without shattering your thoughts over different directions.
Rajshekhar Paul wrote:@Cristian
Why are you with the impression that the garbage collector will do it's job during the for loop execution?
Ankit Garg wrote:... In fact usually you don't need to call System.gc on to free memory. ..
I am mighty! And this is a mighty small ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|