go to previous page   go to home page   go to next page hear noise highlighting

Answer:

Yes. A class is a description of a potential object. It can be used many times to make many objects of the same type.


Use a Class to Make Many Objects

cookie dough and cookie cutters

A class is like a cookie cutter that can be used many times to make many cookies. There is only one cookie cutter, but can be used to make many cookies. Cookies are objects and each one has its own individuality because each one is made out of a different section of dough. Different cookies may have different characteristics, even though they follow the same basic pattern. For example, cookies may have candy sprinkles or frosting, or may be baked for different lengths of time.

Cookies can be created. And cookies can be destroyed (just ask Cookie Monster). But destroying cookies does not affect the cookie cutter. It can be used again if there is dough left.

A big cookie jar might require many cookies made with many different cookie patterns (stars, hearts, squares). A big cookie (such as a gingerbread house) might be built out of many smaller cookies of several different types.

A big program might require many objects created from many classes. Some objects are composed of smaller objects, which themselves are composed of smaller objects. As a program runs, objects come into existance and go out of existance.


QUESTION 11:

(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?


go to previous page   go to home page   go to next page