GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JQ+ question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JQ+ question" Watch "JQ+ question" New topic
Author

JQ+ question

sonir shah
Ranch Hand

Joined: Nov 01, 2001
Posts: 435

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

Joined: Nov 03, 2000
Posts: 267
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

 
GeeCON Prague 2014
 
subject: JQ+ question