Deck 10: Classes and Data Abstraction
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/43
Play
Full screen (f)
Deck 10: Classes and Data Abstraction
1
Which of the following class definitions is correct in C++? 

A
2
If an object is created in a user program, then the object can access both the public and private members of the class.
False
3
A class is an example of a structured data type.
True
4
Consider the UML class diagram shown in the accompanying figure.According to the UML class diagram, how many private members are in the class?
A) none
B) zero
C) two
D) three
A) none
B) zero
C) two
D) three
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
5
You can use arithmetic operators to perform arithmetic operations on class objects.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
6
If a member of a class is ____, you cannot access it outside the class.
A) public
B) automatic
C) private
D) static
A) public
B) automatic
C) private
D) static
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
7
The public members of a class must be declared before the private members.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
8
Consider the accompanying class definition.Which of the following variable declarations is correct?
A) rectangle rectangleType;
B) class rectangleType rectangle;
C) rectangleType rectangle;
D) rectangle rectangleType.area;
A) rectangle rectangleType;
B) class rectangleType rectangle;
C) rectangleType rectangle;
D) rectangle rectangleType.area;
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
9
If an object is declared in the definition of a member function of the class, then the object can access both the public and private members of the class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
10
A ____ sign in front of a member name on a UML diagram indicates that this member is a protected member.
A) +
B) -
C) #
D) $
A) +
B) -
C) #
D) $
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
11
As parameters to a function, class objects can be passed by reference only.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
12
If the heading of a member function of a class ends with the word const, then the function member cannot modify the private member variables, but it can modify the public member variables.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
13
Consider the UML class diagram shown in the accompanying figure.Which of the following is the name of the class?
A) clock
B) clockType
C) Type
D) +clockType
A) clock
B) clockType
C) Type
D) +clockType
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
14
A class and its members can be described graphically using a notation known as the ____ notation.
A) OON
B) OOD
C) UML
D) OOP
A) OON
B) OOD
C) UML
D) OOP
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
15
Given this declaration:myClass myObject;
The following statement is legal.
myObject.x = 10;
The following statement is legal.

Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
16
The word ____ at the end of several the member functions in the accompanying figure class clockType specifies that these functions cannot modify the member variables of a clockType object.
A) static
B) const
C) automatic
D) private
A) static
B) const
C) automatic
D) private
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
17
A ____ sign in front of a member name on a UML diagram indicates that this member is a public member.
A) +
B) -
C) #
D) $
A) +
B) -
C) #
D) $
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
18
The components of a class are called the ____ of the class.
A) elements
B) members
C) objects
D) properties
A) elements
B) members
C) objects
D) properties
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
19
In C++, class is a reserved word and it defines only a data type.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
20
In C++ terminology, a class object is the same as a class instance.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
21
A program or software that uses and manipulates the objects of a class is called a(n) ____________________ of that class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
22
A(n) ____________________ function of a class changes the values of the member variable(s) of the class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
23
A destructor has the character ____, followed by the name of the class.
A) .
B) ::
C) #
D) ˜
A) .
B) ::
C) #
D) ˜
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
24
Consider the accompanying class definition, and the declaration:rectangleType bigRect; Which of the following statements is correct?
A) rectangleType.print();
B) rectangl
A) rectangleType.print();
B) rectangl
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
25
In C++, the scope resolution operator is ____.
A) :
B) ::
C) $
D) .
A) :
B) ::
C) $
D) .
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
26
A class object can be ____.That is, it is created each time the control reaches its declaration, and destroyed when the control exits the surrounding block.
A) static
B) automatic
C) local
D) public
A) static
B) automatic
C) local
D) public
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
27
What does ADT stand for?
A) abstract definition type
B) asynchronous data transfer
C) abstract data type
D) alternative definition type
A) abstract definition type
B) asynchronous data transfer
C) abstract data type
D) alternative definition type
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
28
Non-static member variables of a class are called the ____________________ variables of the class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
29
To guarantee that the member variables of a class are initialized, you use ____.
A) accessors
B) mutators
C) constructors
D) destructor
A) accessors
B) mutators
C) constructors
D) destructor
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
30
If a class object is passed by ____________________, the contents of the member variables of the actual parameter are copied into the corresponding member variables of the formal parameter.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
31
A class object can be ____.That is, it can be created once, when the control reaches its declaration, and destroyed when the program terminates.
A) static
B) automatic
C) local
D) public
A) static
B) automatic
C) local
D) public
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
32
With ____________________ functions, the definitions of the member functions are placed in the implementations file.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
33
Consider the accompanying class and member functions definitions.How many constructors are present in the class definition?
A) none
B) one
C) two
D) three
A) none
B) one
C) two
D) three
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
34
In C++, the ____ is called the member access operator.
A) .
B) ,
C) ::
D) #
A) .
B) ,
C) ::
D) #
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
35
In C++, you can pass a variable by reference and still prevent the function from changing its value by using the keyword ____ in the formal parameter declaration.
A) automatic
B) private
C) static
D) const
A) automatic
B) private
C) static
D) const
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following is true about classes and structs?
A) By default, all members of a struct are public and all members of a class are private.
B) A struct variable is passed by value only, and a class variable is passed by reference only.
C) An assignment operator is allowed on class variables, but not on struct variables.
D) You cannot use the member access specifier private in a struct.
A) By default, all members of a struct are public and all members of a class are private.
B) A struct variable is passed by value only, and a class variable is passed by reference only.
C) An assignment operator is allowed on class variables, but not on struct variables.
D) You cannot use the member access specifier private in a struct.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
37
Consider the accompanying class definition, and the object declaration:rectangleType bigRect(14,10); Which of the following statements is correct?
A) bigRect.setLengthWidth();
B) bigRect.setLengthWidth(3.0, 2.0);
C) bigRect.length = 2.0;
D) bigRect.length = bigRect.width;
A) bigRect.setLengthWidth();
B) bigRect.setLengthWidth(3.0, 2.0);
C) bigRect.length = 2.0;
D) bigRect.length = bigRect.width;
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
38
How many destructors can a class have?
A) no explicit destructors
B) one
C) two
D) any number
A) no explicit destructors
B) one
C) two
D) any number
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
39
A member function of a class that only accesses the value(s) of the data member(s) is called a(n) ____ function.
A) accessor
B) mutator
C) constructor
D) destructor
A) accessor
B) mutator
C) constructor
D) destructor
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
40
If a function of a class is static, it is declared in the class definition using the keyword static in its ____.
A) return type
B) parameters
C) heading
D) main function
A) return type
B) parameters
C) heading
D) main function
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
41
The header file is also known as the ____________________.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
42
A(n) ____________________ contains the definitions of the functions to implement the operations of an object.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
43
A(n) ____________________ is a statement specifying the condition(s) that must be true before the function is called.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck