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

Answer:

Yes. A class is a description of potential objects and can be used many times to make many objects of the same type. The objects do not have to have the same data inside of them, just the same over all plan.

Using 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.


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?