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 doubt!!! 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 "doubt!!!" Watch "doubt!!!" New topic
Author

doubt!!!

sriram gupta
Ranch Hand

Joined: Aug 09, 2001
Posts: 39
hi all,
what will be the output of the following and if u can tell me why it will be very helpful...
class{
int i=valueofi();
int j=10;
int valueofi(){return j;}
}

// the value of i after this is 0 but i couldn't understand why???
swati bannore
Ranch Hand

Joined: Oct 18, 2000
Posts: 201
Hi,
Same code was recently discussed here.
The method is called before iniitialization of variable j to value 10. So method returns the default value of int variable j i.e. 0.
Thanx.


Swati Kale
SCJP
SCWCD
sriram gupta
Ranch Hand

Joined: Aug 09, 2001
Posts: 39
thanx swati....
it is clear now....
Muhammad Farooq
Ranch Hand

Joined: May 08, 2001
Posts: 356
Just try this
class{
int j=10;
int i=valueofi();
int valueofi(){return j;}
}
HTH
--Farooq


Muhammad Farooq<br />Sun Certified Programmer for Java 2 Platform<br />Oracle8i Certified Professional Database Administrator
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt!!!