• Post Reply Bookmark Topic Watch Topic
  • New Topic

Program Output  RSS feed

 
Achint Verma
Greenhorn
Posts: 12
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain why is the output -434 ?
From Kathy & Bates



The explanation given in the text is as:
1.Overloaded var-args are chosen last [OK]
2.Arrays are objects [then for sifter(ba), shouldn't the output be 4, after all its the same as "sifter(aa)"]
3.An int can be boxed to an Integer and then "widened" to an Object.

Thank you.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please always tell us where such examples come from.
Write down the values of the fields in that B class. That would appear to be the String s. Work out which methods are called, in which order. Are you calling the sifter() method with Objects, As or Bs or what? Remember that sort of qwuation will have special features to confuse you.
 
Achint Verma
Greenhorn
Posts: 12
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry but this is a direct question from Kathy & Bates. From the self test questions.
 
abalfazl hossein
Ranch Hand
Posts: 635
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!