Java clarification on instance and static variable usage from within instance and static methods? -
question in book asking: restrictions placed on instance variable , static variable access within definition of: 1.) instance method? 2.) static method?
is response concept correct?
-an instance method cannot directly access instance variable while static variable can directly accessed since 1 copy used throughout class. (each object share static variable static methods in class. instance variable available each object , each object has own copy of instance variable.) static method cannot access instance members of class. static method can access members of static variable.
an instance method cannot directly access instance variable
wrong.
while static variable can directly accessed since 1 copy used throughout class.
correct.
(each object share static variable static methods in class.
correct.
an instance variable available each object , each object has own copy of instance variable.)
correct.
a static method cannot access instance members of class.
correct.
a static method can access members of static variable.
correct, if has members, , accessible.
the compiler have told 100% reliablity.
Comments
Post a Comment