• 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

about reference

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
below is a question from Marcus Green's site.
Given the following code what will be the output?
class ValHold{
public int i = 10;
}
public class ObParm{
public static void main(String argv[]){
ObParm o = new ObParm();
o.amethod();
}
public void amethod(){
int i = 99;
ValHold v = new ValHold();
v.i=30;
another(v,i);
System.out.println(v.i);
}//End of amethod
public void another(ValHold v, int i){
i=0;
v.i = 20;
ValHold vh = new ValHold();
v = vh;
System.out.println(v.i+ " "+i);
}//End of another
}
1) 10,0, 30
2) 20,0,30
3) 20,99,30
4) 10,0,20
who can tell me which answer is correct and why is it correct?
Thank a lot.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rainbow,
Did you know we have a search facility to browse through previously discussed subjects? This particular question has been discussed here before and here are the results - http://www.javaranch.com/cgi-bin/ubb/search.cgi?action=simplesearch&SearchIn=ALL&ForumChoice=24&SearchTerms=ValHold&BooleanAND=YES&SearchDate=ALL&SearchUser=&ExactName=no&File=temp -2451801-151503-qtws.cgi&Total=5&StartAt=10000

I hope you find the answers you were looking for in these discussions. I encourage you to use the search facility in future. For all you know your question might be there and you don't have to wait for answers anymore!!
Good luck,
Ajith
[This message has been edited by Ajith Kallambella (edited September 13, 2000).]
[This message has been edited by Ajith Kallambella (edited September 13, 2000).]
 
rainbow
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you ,Ajith Kallambella.
but if I use the search tool,what search word can I fill?I don't know how the serarch engine work.do you know about it?
rainbow
 
moose poop looks like football shaped elk poop. About the size of 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