The book is correct. What the book means is not that objects of a class cannot access static members of the class, but that no static members of the class will be stored in the object. When an object needs to access static members, it first finds the class itself, and then accesses the static members in it.
So in your example, owner and amount exist in objects, while interestRate exists in classes. When accessing this static variable, you need to find the class first and then find the variable.
Because static members of a class are shared by all objects, if they are stored in each object, when one object modifies the variable, other objects will not be able to see the modified result. This is consistent with the characteristics of static members. is inconsistent.
The book is correct. What the book means is not that objects of a class cannot access static members of the class, but that no static members of the class will be stored in the object. When an object needs to access static members, it first finds the class itself, and then accesses the static members in it.
So in your example,
owner
andamount
exist in objects, whileinterestRate
exists in classes. When accessing this static variable, you need to find the class first and then find the variable.Because static members of a class are shared by all objects, if they are stored in each object, when one object modifies the variable, other objects will not be able to see the modified result. This is consistent with the characteristics of static members. is inconsistent.