

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Reading - Quiz โ Monday, March 28 Last time we looked at:
A class variable is independent of the objects in the class. There is only one instance of a class variable, regardless of how many objects exist. Math.PI is a defined as a class variable (actually a constant because it's final). Let's look at a class that includes a class variable - Counter.java The methods reset(), getValue(), and click() should all be pretty familiar to you - they are instance methods. Method getHowMany() is a class method - note the keyword static The variable howMany is a class variable - again, note the keyword static. howMany gets initialized to 0, and is incremented everytime the Counter constructor is invoked. [Draw picture] Scope We've seen that variables can only be used in certain parts of a program