• Post Reply Bookmark Topic Watch Topic
  • New Topic

JQ+ question  RSS feed

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!