aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt in output of the program 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 in output of the program" Watch "doubt in output of the program" New topic
Author

doubt in output of the program

Jyothsna Panchagnula
Ranch Hand

Joined: Jul 11, 2005
Posts: 113
Source:http://www.go4java.20m.com/mock1.htm


Why is the output of the program not recursive?
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Hi Jyothsna,

What makes you think there is recursion in the code? The method abc() doesn't call itself anywhere directly or indirectly.


All code in my posts, unless a source is explicitly mentioned, is my own.
geeta vemula
Ranch Hand

Joined: Jul 18, 2008
Posts: 208
Then what is the correct output? I think its option 4.Is it right?

Thanks,
Geeta.v
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Yes, it should output 0. You are not initializing the static variable, but the shadowing local variable.
Shwetha Sharma
Ranch Hand

Joined: Jun 01, 2008
Posts: 34


You are not initializing the static variable, but the shadowing local variable.


Hi Rubin,
what do you mean by the above statement?


SCJP6:80%, OCWCD 88 %
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Originally posted by Shweta S Sharma S:


Hi Rubin,
what do you mean by the above statement?

Hi Shweta,

Sorry for the misunderstanding, this is my mistake. I misread the static variable declaration and I thought its name was i as well.
:roll:
There is no shadowing going on because the static variable has a different name.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: doubt in output of the program