File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K and B Chapter 3 self test qn no 12

 
kiruthigha rajan
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What is the result?
A. 4 4
B. 5 4
C. 6 4
D. 4 5
E. 5 5
F. Compilation fails

can anyone explain how the answer is A.im confused with values passed here..

 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ba[0] and ba[1] both holds the reference b1 which has its size set as 4 in the go() method.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
read this small Story
 
kiruthigha rajan
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Jai wrote:ba[0] and ba[1] both holds the reference b1 which has its size set as 4 in the go() method.


When Box[] ba = go(b1, new Box(6)); reaches the go method the value contained is 5 and 6
then b1.size becomes 4,and b2 remains 6
this is placed in an array ma wer b2,b1 contains 6,5
then ma and ba shares the same array object.
here ba[0] is assigned to b1 which is 4
so this prints 4,4
am i right??
correct me if i am wrong..
thanks in advance
 
Praveen Kumar M K
Ranch Hand
Posts: 256
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kiruthigha rajan wrote:
John Jai wrote:ba[0] and ba[1] both holds the reference b1 which has its size set as 4 in the go() method.


When Box[] ba = go(b1, new Box(6)); reaches the go method the value contained is 5 and 6
then b1.size becomes 4,and b2 remains 6
this is placed in an array ma wer b2,b1 contains 6,5
then ma and ba shares the same array object.
here ba[0] is assigned to b1 which is 4
so this prints 4,4
am i right??
correct me if i am wrong..
thanks in advance


At line 16, "ma" contains 6,4 owing to the assignment in the previous step.
 
kiruthigha rajan
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At line 16, "ma" contains 6,4 owing to the assignment in the previous step

yeah typing mistake...
thanks alot
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic