Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Programmer Certification (OCPJP)
Mock question for static method?
Sam Sunamin
Ranch Hand
Posts: 113
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What's the result of the following code?
public class Question36 { private static int x=getValue(); private static int y=5; public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(x); } private static int getValue() { return y; } }
The code above is compiled and run, but the suprised thing is that the result is
print - 0;
Can anyone explain? Thanks in advance.
Yours Sam<br />SCJP5.0 97%<br />SCBCD5.0 72%
Stuart Ash
Ranch Hand
Posts: 637
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Didn't we discuss this before?
Am I getting a deja vu !!
ASCII silly question, Get a silly ANSI.
Sam Sunamin
Ranch Hand
Posts: 113
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can you post the link for me? I did not get the post?
Thank you.
Yours Sam<br />SCJP5.0 97%<br />SCBCD5.0 72%
Stuart Ash
Ranch Hand
Posts: 637
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Voila -
here it is!
ASCII silly question, Get a silly ANSI.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
forward referencing
initialization of static variables
Using a variable before it has been initialised
compile time constants
string concatenation with integer
More...