Exam 14: Inheritance

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

What are the benefits of inheritance and Object Oriented Programming?

Free
(Essay)
4.8/5
(37)
Correct Answer:
Verified

The benefits are abstraction and code reuse: A general form of a class can be defined.It contains common features of the several specialized versions that may be defined and caused to inherit from the general form.This saves you the trouble of writing identical code two or more times.
Though the text does not say this explicitly,inheritance and OOP better enable modeling of problems within programs.The objects represent actors and the member functions represent behavior of the actors.The data members are information the actors must remember to carry out their prescribed behavior.

A base/member initialization list is preceded by

Free
(Multiple Choice)
4.8/5
(33)
Correct Answer:
Verified

C

If B is a public base class of D,then D's members cannot invoke public members functions of B.

Free
(True/False)
4.9/5
(39)
Correct Answer:
Verified

False

A programmer can use inheritance with an existing library for which only the header file and binary are available,to derive a class more suitable to her purpose.

(True/False)
4.8/5
(43)

In C++,inheritance has much to do with the gene pool.Explain.

(True/False)
4.7/5
(32)

If class D is derived from class B then class D has only some of the members from B,and the additional members defined in D.

(True/False)
4.8/5
(32)

We can assign a base class object to a derived class variable.

(True/False)
4.8/5
(32)

Given the class below,tell to what value the default constructor initializes the data member.Name this initialization technique and give another way to write the constructor. class A { public: A(); private: int a; }; A::A(): a(17) { //deliberately empty }

(Essay)
4.9/5
(34)

Constructors are inherited.After all something has to initialize the inherited variables.

(True/False)
4.9/5
(37)

When a derived class inherits from a base class,how is the base class constructor called?

(Essay)
4.9/5
(40)

Suppose class Child is derived from class Parent that was in turn derived from class GrandParent.When we destroy an object of class Child,three destructors are called: i)Child,ii)Parent,iii )GrandParent..What is the order?

(Multiple Choice)
4.9/5
(43)

If a base class constructor is not called explicitly in the definition of a derived class constructor,an error results.

(True/False)
4.9/5
(42)

If a class B is a pubic base class for a derived class D,then an object of class D bears what relationship to class B?

(Multiple Choice)
4.7/5
(33)

Suppose class Child is derived from class Parent that was in turn derived from class GrandParent.When we declare an object of class Child,three constructors are called: i)Child,ii)Parent,iii )GrandParent..What is the order?

(Multiple Choice)
4.7/5
(38)

If B is a base class of D,then D's members cannot access the private data members of B without regard to the kind of inheritance.

(True/False)
4.8/5
(34)

If B is a base class of D,then D's members cannot invoke private member functions of B without regard to the kind of inheritance.

(True/False)
4.8/5
(37)

In the code for HourlyEmployee that is derived from Employee,the constructor code appears HourlyEmployee:: HourlyEmployee(string theName, string theNumber, double theWageRate, double theHours ) : Employee(theName,theNumber), wageRate(theWageRate), hours(theHours) { // deliberately empty } Describe the purpose of the items after the colon (:)in this code.

(Essay)
4.8/5
(43)

When class D is derived from class B,the derived class is usually smaller.Explain.

(True/False)
4.8/5
(35)

Neither the assignment operator overloading nor the copy constructor is inherited.If you do not create one,does this mean that the derived class will have no assignment operator or copy constructor?

(Essay)
4.9/5
(36)

An inheritance chain of any desired length is possible.

(True/False)
4.8/5
(48)
Showing 1 - 20 of 30
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)