Answer the following questions about object-oriented programming, using this chapter and explorations on the Web.
1. What is the difference between an instance and a class?
2. How are functions and methods different?
3. How is object-oriented programming different from procedural programming?
4. What is polymorphism?
5. What is encapsulation?
6. What is aggregation?
7. What is a constructor?
8. How did biological cells influence the development of the idea of objects?
1. A class is like a blueprint for an instance. The instance is the thing that we can make use of, while the class is just a set of instructions on how to make it.
2. Functions are “outside” a class, while methods are “inside” a class. A method can only be called through an instance of a class, while a functil can be called without one.
3. Procedural programming is programming with “verbs” while object-oriented programming is programming with “nouns”. Both are just styles for getting programs done, with procedural programming focusing on just creating functions that do things, and object oriented programming focusing on creating objects that do things.
4. When the same name can be used to invoke different methods to achieve the same goal.
5. Encapsulation is a feature of object-oriented programming in which data and behaviors are accessible in one and only one place.
6. Aggregation is a feature of object-oriented programming in which lots of different data can be stored in the same type of object, such that many objects are stored instead of many individual classes.
7. A constructor is the method of a class that allows for the construction of a new instance of that class.
8. Alan Kay referred to them as an example of the way that computer science objects would work together like how cells work together to make a whole organism work.