• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Marcus Green exam question

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
The moustache of a titan! The ad of a flea:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic