• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Certification4career.com

 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All..
I came across this website and they have a free mock exam
I have a question i wanted to discuss about
please select true statement(s) for static modifier.
a.A static method can access non-static variables of the class.
b.A static method can call non-static methods.
c.A static method can be overridden by non-static method.
d. None of the above
Ans: d
But arent a and b true?
I mean we can access non-static members from main method via
an object reference, and since main being always static, wont the chocices a and b be true?
Can Some one clarify this for me please?
Thankx in advance
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ragu,


I mean we can access non-static members from main method via
an object reference, and since main being always static, wont the chocices a and b be true?


You are right you can access non-static variable via object reference. But the choice a or b doesn't mention via object reference.
Vanitha.
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vanitha Sugumaran:
Hi Ragu,
You are right you can access non-static variable via object reference. But the choice a or b doesn't mention via object reference.
Vanitha.


Thankx Vanitha,
But here is a thought... choice a and b arent they pretty much imply the object reference? or is there any another way to access
non-static variable from static method, without object reference?
Any ideas?

 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ragu,
Usually you have to accept the question as it's worded. Accessing non-static variables via an object reference is not given as a choice. If you try to second guess every question in a mock, or on the real exam (where the questions are clearly worded) you'll give yourself a major headache
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK!! You gave me a good point.
I will follow that procedure, with out thinking too much
of hidden or implicit answers of the choices
Thank you Jane, you are always my savior
 
reply
    Bookmark Topic Watch Topic
  • New Topic