Forums Register Login

JQ+ question

+Pie Number of slices to send: Send

Question ID :953843674880

public class TestClass
{
char c;
public void m1()
{
char[ ] cA = { 'a' , 'b'};
m2(c, cA);
System.out.println( ( (int)c) + ", " + cA[1] );
}
public void m2(char c, char[ ] cA)
{
c = 'b';
cA[1] = cA[0] = 'm';
}
public static void main(String args[])
{
new TestClass().m1();
}
}

The Answer is : 0,m
Can any one explain me how do we get this answer with proper explanation
Sonir
+Pie Number of slices to send: Send
the following link will explain the answer to your question
http://www.javaranch.com/campfire/StoryPassBy.jsp

Originally posted by sonir shah:

Question ID :953843674880

public class TestClass
{
char c;
public void m1()
{
char[ ] cA = { 'a' , 'b'};
m2(c, cA);
System.out.println( ( (int)c) + ", " + cA[1] );
}
public void m2(char c, char[ ] cA)
{
c = 'b';
cA[1] = cA[0] = 'm';
}
public static void main(String args[])
{
new TestClass().m1();
}
}

The Answer is : 0,m
Can any one explain me how do we get this answer with proper explanation
Sonir


And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 665 times.
Similar Threads
super of super
doubt on object
compile-time constant
Jq + Question ID :988380923984
final modifier
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:08:58.