wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from Marcus Green 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 "Question from Marcus Green " Watch "Question from Marcus Green " New topic
Author

Question from Marcus Green

aishwarya mathur
Greenhorn

Joined: Sep 03, 2004
Posts: 22
I think I'am going wrong somewhere,u may find it simple, here in the below code, as method <amethod> is non-static ,is it ok if we try to access variable j which is static.

Inuka Vincit
Ranch Hand

Joined: Aug 10, 2004
Posts: 175
yes its ok.
its only static methods that cant access instance varibles, instance methods can access static veraibles.


MCP (C# application dev 70-316) 860<br />SCJP 1.4 100% SCJD (URLyBird) 378<br />MAD 100% nuts
Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
Hi
I think the crux is one can't access non-static var. from within a static method.
the vice -versa is not true.
HTH
Kosh Shah
Greenhorn

Joined: Jul 20, 2004
Posts: 19
And the output for the above code is:
10, and 40. Right?

Correct me if I am wrong!

Cheers,
Kosh!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question from Marcus Green