The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Marcus Green exam question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Marcus Green exam question" Watch "Marcus Green exam question" New topic
Author

Marcus Green exam question

Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126

I looked at the above line in Exam 3, Question 45 of Marcus Greens Mock tests. I was wondering one thing....
How can the static method main() access the court variable of s?
I tried placing a similar sample of code in my compiler, and was unable to compile it.
By the way, the answer given is 4.

Can someone explain?
Thanks
Zak Nixon
Vivek Mongolu
Ranch Hand

Joined: Apr 17, 2003
Posts: 42
How can the static method main() access the court variable of s?

In the main method court variable is accessed thru the object which is fine but if you try to access the court variable without the object then it will give u compile time error saying that static method can only access static variables

Vivek
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Marcus Green exam question
 
Similar Threads
Marcus Green #3 Q45
get method
Sample question
Help for the visibility of private access modifier
private member doubt