Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock question.

 
jamil lusa
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, i am practising the mock test questions from the OCP java SE 6 Programmer Practice Exams. There is a question i could not figure out:



What do you all think about the answer?
 
John Stark
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think forandboth this and b in the go() method refer to the same object. Therefore this can be replaced by b which makes it a bit more readable.
In the case of go() is called from within go(). Thereforeis done twice resulting in being 7. The answer is 2 7 then.

John
 
Jagdev Singh
Ranch Hand
Posts: 71
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think answer should be 2 7.
The question is related to method call using reference variables.

hth
Jagdev
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic