Deck 2: Object-Oriented Design OOD and C++
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/35
Play
Full screen (f)
Deck 2: Object-Oriented Design OOD and C++
1
The base class inherits all its properties from the derived class.
False
2
In single inheritance, the derived class is derived from a single base class.
True
3
Private members of a base class can be accessed by a derived class.
False
4
The derived class can redefine public member functions of a base class.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
5
Overriding a member function is the same as redefining it.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
6
Redefining a member function is the same as overloading the member function.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
7
A class cannot have a constructor with default parameters.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
8
A derived class cannot have a constructor with default parameters.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
Header files of new classes contain commands that tell the computer where to look for definitions of the base class.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
10
In C++ the user can create new operators.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
11
Default arguments can be used with an overloaded operator.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
12
When overloading an operator, the meaning of how an operator works with built-in types remains the same.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
13
A friend function is a member function of a class but only has access to the class's public data members.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
14
The function that overloads any of the operators (), [], ->, or = for a class must be declared as a member of the class.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
15
For efficiency purposes, wherever possible, you should overload operators as nonmember functions.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
16
By using templates, you can write a single code segment for a set of related functions.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
17
Just as variables are parameters to functions, data types are parameters to templates.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
18
In single inheritance, the derived class is derived from ____base class(es).
A) one
B) two
C) three or more
D) virtual
A) one
B) two
C) three or more
D) virtual
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
19
If there are three classes, shape, circle, and square, what is the most likely relationship among them?
A) The square class is a base class, and shape and circle are derived classes of square.
B) The shape class is a base class, and circle and square are derived classes of shape.
C) The shape, circle, and square classes are all sibling classes.
D) These three classes cannot be related.
A) The square class is a base class, and shape and circle are derived classes of square.
B) The shape class is a base class, and circle and square are derived classes of shape.
C) The shape, circle, and square classes are all sibling classes.
D) These three classes cannot be related.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
20
If class dog has a derived class retriever, which of the following is true?
A) In the case of single inheritance, dog can have no other derived classes.
B) In the case of single inheritance, retriever is derived from no other class except dog.
C) The relationship between these classes implies that dog "is a" retriever.
D) The relationship between these classes implies that retriever "has-a" dog.
A) In the case of single inheritance, dog can have no other derived classes.
B) In the case of single inheritance, retriever is derived from no other class except dog.
C) The relationship between these classes implies that dog "is a" retriever.
D) The relationship between these classes implies that retriever "has-a" dog.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
21
We need to ensure that the private member variables that are inherited from the base class are initialized when a ____ of the derived class executes.
A) destructor
B) constructor
C) copy constructor
D) friend function
A) destructor
B) constructor
C) copy constructor
D) friend function
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
22
When you declare a derived class object, this object inherits the members of the base class, but the derived class object cannot directly access the ____.
A) private data members of the base class
B) data members in its own class
C) base class constructors
D) public data members of the base class
A) private data members of the base class
B) data members in its own class
C) base class constructors
D) public data members of the base class
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
23
A(n) ____ typically serves to initialize the member variables of a derived class.
A) inheritor
B) initiator
C) deconstructor
D) constructor
A) inheritor
B) initiator
C) deconstructor
D) constructor
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
24
A call to the base class constructor is specified in the ____ of a derived class constructor.
A) body of the definition
B) body of the constructor
C) heading of the definition
D) heading of the constructor
A) body of the definition
B) body of the constructor
C) heading of the definition
D) heading of the constructor
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
25
If a class contains the default constructor and no values are specified when the object is declared, the ____ executes and initializes the object.
A) default destructor
B) first destructor in the program listing
C) last constructor in the program listing
D) default constructor
A) default destructor
B) first destructor in the program listing
C) last constructor in the program listing
D) default constructor
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
26
To define new classes, you create new ____ files.
A) header
B) friend
C) prototype
D) placeholder
A) header
B) friend
C) prototype
D) placeholder
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
27
The definitions of member functions can be placed in a separate file whose extension is ____.
A) .cxx
B) .c
C) .cpp
D) .cc
A) .cxx
B) .c
C) .cpp
D) .cc
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
28
To include a system-provided header file, such as iostream, in a user program, you enclose the header file between ____.
A) curly brackets
B) angular brackets
C) asterisks
D) square brackets
A) curly brackets
B) angular brackets
C) asterisks
D) square brackets
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
29
To include a header file in a program, you use the preprocessor command ____.
A) pragma
B) fetch
C) pull
D) include
A) pragma
B) fetch
C) pull
D) include
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
30
For a base class to give access to a member to its derived class and still prevent its direct access outside the class, you must declare that member under the member access specifier ____.
A) private
B) protected
C) public
D) shared
A) private
B) protected
C) public
D) shared
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
31
In ____, one or more members of a class are objects of another class type.
A) inheritance
B) redefinition
C) composition
D) encapsulation
A) inheritance
B) redefinition
C) composition
D) encapsulation
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
32
Composition is a(n) "____" relationship.
A) is a
B) has a
C) was a
D) had a
A) is a
B) has a
C) was a
D) had a
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
33
The arguments to the constructor of a member object are specified in the ____ part of the definition of the constructor of the class.
A) body
B) pragma
C) scope
D) heading
A) body
B) pragma
C) scope
D) heading
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
34
By using templates, you can write a single code segment for a set of related functions, called a ____.
A) function template
B) function type
C) class set
D) class template
A) function template
B) function type
C) class set
D) class template
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
35
Passing parameters to a function has an effect at ____ time.
A) compile
B) link
C) run
D) build
A) compile
B) link
C) run
D) build
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck