OOP Demystified

1.  

What is an object?

2.  

What is an attribute of an object?

3.  

What is a behavior of an object?

4.  

Why it is important for programmers to use object-oriented programming to develop computer systems?

5.  

Explain the role of inheritance in object-oriented programming.

6.  

How can object-oriented programming help maintain complex computer systems?

7.  

Identify the attributes of the order form in Figure 1-1.

8.  

Identify the behaviors of the order form in Figure 1-1.

9.  

Describe objects in a college that might inherit a Person object.

10.  

Draw a diagram that shows the relationships of objects that you listed in your answer to Question 9.

Answers

1.  

An object is a person, place, thing, concept, or possibly event.

2.  

An attribute is a characteristic of an object.

3.  

A behavior is an action that an object is capable of performing.

4.  

Focusing on objects makes it easy for us to understand complex things. Objects enable us to look at details that are of interest to us and ignore other details that we are not interested in.

5.  

Inheritance is a way for one object to receive attributes and behaviors of another object in what programmers call an is a relationship.

6.  

Attributes and behaviors need to be defined in one object, such as Person. Other objects that require those attributes and behaviors ”such as Student, Teacher, Department Chair, Dean, Secretary, and Bursar ”can inherit the object. This allows for attributes and behaviors to be defined in only one object, making it easy to add new attributes and behaviors or remove existing attributes and behaviors.

7.  

The attributes of the order form in Figure 1-1 are as follows :

  • Customer Name

  • Customer Address

  • Customer Number

  • P.O. Number

  • Date Shipped

  • Shipped Via

  • Required Date

  • Terms

  • Quantity

  • Item ID

  • Item Name

  • Unit Price

  • Amount

  • Subtotal

  • Sales Tax

  • Shipping & Handling

  • Total Due

8.  

The behaviors of the order form in Figure 1-1 are as follows:

  • Enter order information

  • Modify order information

  • Delete order

  • Process order

  • Look up order

9.  

These are common objects that inherit a Person object:

  • Student

  • Instructor

  • Dean

  • President

  • Board of Trustees

  • Security Manager

  • Security Guard

  • Bookstore Manager

  • Sales Assistant

  • Department Chair

  • Bursar

  • Registrar

  • Maintenance Manager

  • Maintenance Worker

  • Secretary

10.  

See Figure B-1.

Категории