Page 1 of 1

static variable

Posted: Sat Feb 09, 2013 8:51 pm
by user
question 29 of standard test 11:

would class A and TestClass (extends A) have different copies of static variable i? One static variable i belongs to class A and the other belongs to TestClass. When the run methods of Class A and TestClass execute, they should incease their own copy of the static varible i, rather than update the same i?

Re: static variable

Posted: Sat Feb 09, 2013 9:13 pm
by admin
No, TestClass doesn't declare its own static variable i. so there is no static variable i in TestClass. There is only one in class A. However, since TestClass extends A, you can do TestClass.i but it would still access A's i.

HTH,
Paul.