File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Accessing variables inside method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Accessing variables inside method" Watch "Accessing variables inside method" New topic
Author

Accessing variables inside method

Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 92
source: irix technologies



The answer is 55667766. i can trace the answer upto 556677,but i am not sure why System.out.print( voo.doo.doolet ); gives 66 in the end?

Thanks in advance


SCJP 6.0
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

The secret is in line number 7, when doo = new Doo( ); is executed, the doo in voolish method starts pointing to a different object of type Doo, so the actual doo object passed to the method isn't effected when we set doo.doolet to 77. Read this, it will clear your doubts...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing variables inside method
 
Similar Threads
Why? null is not a common object,then what it is?
new method
exception question
Confusion with Javac Compiler
why is that output ?