Chapter 13                  Object-Oriented Programming

 

1.     Member variables in a class are normally specified as Private.  (T/F)

 

2.     Property Let statements are used to assign values to member variables.  (T/F)

 

3.     Property Get statements are used to retrieve values of member variables.  (T/F)

 

4.     The Initialize event procedure is automatically invoked when an object is created from a class.  (T/F)

 

 

5.     Two instances of the same class may exist in a single program.  (T/F)

 

6.     An object can be created with the pair of statements. (T/F)

 

   Private pupil As CStudent  'In General Declaration section

   pupil = New CStudent  

 

7.   A class specifies the properties and methods that will be common to all objects that are instances of that class. (T/F)

 

8.   A good rule of thumb for object‑oriented programming is that classes are the verbs in your analysis of the problem. (T/F)

 

9.   An object is an encapsulation of data and procedures that act on that data. (T/F)

 

10.  An object is a template from which classes are created. (T/F)

 

11. If member variables are declared as Private, they cannot be accessed directly from outside an object. (T/F)

 

 

12.  Methods can be either Sub or Function procedures. (T/F)

 

13.   Which line of code will declare a new object variable called instructor in a class called faculty?

(A)  Private faculty As instructor

(B) Private instructor As faculty

(C)  Set faculty = New instructor

(D) Set instructor = New faculty

(E) Let instructor = New faculty

   

 

14. What is the purpose of the Private Property Get procedure?

(A) to retrieve values

(B) to assign values

(C)  to access private methods

(D) to verify the data

(E) a Get procedure should never be private

   

 

15.  Which procedure will set default values for member variables when an object is created?

(A) Let

(B) Get

(C)  Public Property

(D) class module

(E)none of the above

 

 

16. A collection of objects is an ordered set of objects where the objects are identified by the numbers 1, 2, 3, .... (T/F)

 

17.  Which one of the following statements deletes the nth object from a collection?

 

        (A) Dim collectionName As New Collection

        (B) collectionName.Add objectName

        (C) collectionName.Remove n

        (D). collectionName.Count

 

18.  At the time an item is added to a collection, we can associate a key for the item via which one of the following statements?

 

        (A) collectionName.define objectname keyString

        (B) collectionNameAdd objectname, keyString

        (C) collectionNameKeyon objectname, keyString

        (D) use keyString as key for objectname

 

19.  A class named CGrades has a public function named AvgGrade. An instance of that class is the seventh object of a collection named Gradebook. Which statement invokes that function?

(A) picBox.Print Gradebook.Item(7).AveGrade

(B) picBox.Print Gradebook.Item(n).AveGrade

(C)  picBox.Print CGrades.Item(7).AveGrade

(D)  picBox.Print Gradebook.CGrades(7).AveGrade

(E) it cannot be invoked in a collection

  

 

20.  What is the best reason for using a key to identify an object in a collection?

(A) to identify the object

(B) the position that it takes in the collection does not have to be known

(C)  to simplify the code

(D)  to increase efficiency

(E) it takes less memory

 

 

In Exercises  21-26, fill in the blank with one of the following six words:

       a. user-defined        b. polymorphism       c. Terminate

       d. interface              e. uses                        f. accessor

 

21.  The set of properties, methods, and events for a class is called a class _____________ .

 

 

22.  The counterpart to the Initialize event is the _____________ event procedure.

 

 

23. The feature that two classes can have behaviors that are named the same and have essentially the same purpose but different implementations is called _____________ .

 

 

24. In a class module, a property is implemented by two procedures, one to set and the other to retrieve the property value. These procedures that access properties are sometimes referred to as _____________ methods.

 

 

25. In addition to the two predefined events for classes, Initialize and Terminate, other events can be defined by the programmer to communicate changes of properties, errors, and the progress of lengthy operations. Such events are called _____________ events.

 

 

26.  One class_____________ another class if it manipulates objects of that class.