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
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.
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?
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
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