|
(Thought question.) Cookies in the real world are objects, of course. But real world cookie cutters are objects too. Do you think that a Java class has an object-like nature, just as does a cookie cutter? A good answer might be:Yes. In order for a plan to be followed, it has to somehow exist. |
StaticClasses are mostly used to create objects, just as a cookie cutter is mostly used to create cookies. But a class has an existence, just as a cookie cutter has an existence. A class and its objects are different types of things, just as a cookie cutter and its cookies are different types of things. A cookie cutter has characteristics that are not shared with cookies. For example, a cookie cutter is made of steel and has sharp edges. After a cookie cutter has been used for a while, there will be many cookies (soft, rounded, doughy things) but still only one thing made of steel with sharp edges. In the Java language, characteristics of a class definition (but not of its objects) are called static. There is only one class definition for a given class, so when a program is running, if something is static then there is only one of it. You can think of the word static as meaning "no matter how many objects are made, there will be only one of these." |
QUESTION 12:Recall the three properties of objects: identity, state, and behavior. Do you expect that a class definition will have its own state and behavior? Click Here after you have answered the question |