Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Originally posted by sudharsan tettu:
Whate could be the output of the following program
i expected 1 1 1 [even though a nd b passed by value but a ,b are
common to both ]
but its printing 101;
please explain
Sunil.V<br />SCJP2, SCWCD1.4, SCBCD1.3
SCJP 1.4
All the knowledge that the world has ever received comes from the mind; the infinite library of the universe is in your own mind - Swami Vivekananda
even though a and b passed by value but a ,b are
common to both
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
rgrds,
Khushhal
public void g(int b,int[] c){
a=1;
b=1;
c[0]=1;
}
rgrds,
Khushhal
as there is no local variable a in method f()..
It's only the instance variable a which is there..
And it's value has changed in method g(int b,int[] c)
rgrds,
Khushhal
Don't get me started about those stupid light bulbs. |