Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Chapter 15 Starting out with C++ Inheritance Polymorphism and Virtual Functions


 

Download  file with the answers

Not a member!
Create a FREE account here to get access and download this file with answers


 

Chapter Fifteen

MULTIPLE CHOICE

1. _________ allows us to create new classes based on existing classes.
a. Polymorphism
b. Inheritance
c. Function overloading
d. The copy constructor
e. None of these

2. When you derive a class from an existing class, you _________ add new data and functions.
a. may never
b. may sometimes
c. may
d. None of these

3. The base class access specification determines how ___________ members in the base class may be accessed by derived classes.
a. private
b. public
c. protected
d. a, b, and c
e. None of these

4. _________ members of a base class are never accessible to a derived class.
a. Public
b. Private
c. Protected
d. a, b, and c
e. None of these

5. The ________ constructor is called before the _______ constructor.
a. base, derived
b. derived, base
c. public, private
d. private, public
e. None of these

6. A __________ of a base class expects to be overridden in a derived class.
a. constructor function
b. destructor function
c. static function
d. virtual function
e. None of these

7. The term __________ means the ability to take many forms.
a. inheritance
b. polymorphism
c. member function
d. encapsulation
e. None of these

8. When the compiler binds a member function call with the version of the function that resides in the same class as the call itself, this is considered __________ binding.
a. local
b. safe
c. static
d. dynamic
e. None of these

9. The compiler performs __________ on virtual functions.
a. static binding
b. dynamic binding
c. additional error checking
d. no special services
e. None of these

10. _____________ to a base class may be assigned the address of a derived class object.
a. Access specifiers
b. Static members
c. Private members
d. Pointers
e. None of these

11. When more than one class is derived from a base class, the situation is called:
a. polymorphism
b. population
c. multiplicity
d. encapsulation
e. None of these

12. When a derived class has two or more base classes, the situation is known as __________.
a. multiple inheritance
b. polymorphism
c. encapsulation
d. access specification
e. None of these

13. Multiple inheritance opens the opportunity for a derived class to have ___________ members.
a. dynamic
b. private
c. public
d. ambiguous
e. None of these

14. In the statement class car : public vehicle, which is the base class?
a. car
b. vehicle
c. public
d. class
e. None of these

15. Arguments are passed to the base class destructor function by the ________ class __________ function.
a. derived, constructor
b. derived, destructor
c. base, constructor
d. base, destructor
e. None of these

16. The following statement

class Car : private Vehicle

allows the __________ members of the Car class to access ___________ members of the Vehicle class.

a. private, private
b. public, private
c. protected, private
d. public, protected
e. None of these

17. In an inheritance situation, the new class that you create from an existing class is known as the ____________.
a. derived class
b. inheritee
c. child class
d. a and c
e. None of these

18. The base class’s __________ affects the way its members are inherited by the derived class.
a. name
b. return data type
c. access specification
d. a and b
e. None of these

19. Protected members of a base class are like _________, but they may be accessed by derived classes.
a. constructor functions
b. static members
c. private members
d. public members
e. None of these

20. The ________ destructor is called before the _______ destructor.
a. base, derived
b. derived, base
c. public, private
d. private, public
e. None of these

21. ____________ is commonly used to extend a class, or to give it additional capabilities.
a. Inheritance
b. Privacy
c. The constructor
d. The destructor
e. None of these

22. When member functions behave differently, depending upon which object performed the call, this is an example of ___________.
a. chaos theory
b. virtual insubordination
c. polymorphism
d. encapsulation
e. None of these

23. A virtual function is a member function that expects to be _________ in a derived class.
a. ignored
b. called frequently
c. overridden
d. private
e. None of these

24. A virtual function is declared by placing the keyword _______ in front of the return type in the base class’s function declaration.
a. virtual
b. private
c. public
d. protected
e. None of these

25. Multiple inheritance is when a _________ class has ___________ base classes.
a. base, no
b. derived, two or more
c. derived, no
d. compound, more than two
e. None of these

26. In the following statement

class Car : protected Vehicle

which is the derived class?
a. Car
b. Vehicle
c. protected
d. cannot be determined
e. None of these

27. In the following statement

class car : protected vehicle

what is being protected?
a. derived class functions
b. base class members
c. derived class data
d. future inherited classes
e. None of these

28. Polymorphism is when ____________ in a class hierarchy perform differently, depending upon which object performs the call.
a. base class constructors
b. derived class destructors
c. member functions
d. derived class constructors
e. None of these

29. __________ functions are dynamically bound by the compiler.
a. Constructor
b. Destructor
c. Static
d. Virtual
e. None of these

TRUE/FALSE

1. True/False: In an inheritance situation, you may not pass arguments to a base class constructor.

2. True/False: More than one class may be derived from a base class.

3. True/False: A derived class may become a base class, if another class is derived from it.

4. True/False: The base class access specification can be viewed as a filter that base class members must pass through when becoming inherited members of a derived class.

5. True/False: When arguments must be passed to the base class constructor, they are passed from the derived class constructor’s header line.

6. True/False: A member function of a derived class may not have the same name as a member function of a base class.

7. True/False: Static binding occurs when the compiler binds a function call with the function call that resides in the same class as the call itself.

8. True/False: Pointers to a base class may be assigned the address of a derived class object.

9. True/False: A derived class may not have any classes derived from it.

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!