• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JQ+ question

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic