This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQ+ question

 
sonir shah
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
 
Roopa Bagur
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic