Exam 15: Inheritance

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

If you have the following class definitions,which of the following is the proper way to construct an object of the derived class? Class Pet { Public: Pet); Void printPet); String getName); Void setNamestring newName); Private: String name; }; Class Dog:public Pet { Public: Dog); Void printPet); Void setTypestring newType); String getType); Private: String type; };

(Multiple Choice)
4.9/5
(43)

An object of a derived class can be stored in a base class variable

(True/False)
4.7/5
(41)

If you use the keyword virtual in a function declaration,you must also use it in the function definition.

(True/False)
4.9/5
(32)

A base class may have at most _______ child class derived from it.

(Multiple Choice)
4.8/5
(43)

Which of the following should be virtual if a base class uses dynamic memory allocation?

(Multiple Choice)
4.7/5
(35)

The assignment operator is inherited from the base class.

(True/False)
4.9/5
(37)

Polymorphism refers to

(Multiple Choice)
4.9/5
(31)

If the member variables in a base class are private,then

(Multiple Choice)
4.8/5
(30)

When the derived class gets all the member variables from the base class,we say that they are _________ from the base class.

(Short Answer)
4.8/5
(37)

The constructor for a class is inherited.

(True/False)
4.8/5
(35)

All member functions in a base class should be listed as virtual functions.

(True/False)
4.8/5
(41)

When we derive one class from another class,this is known as ____________

(Short Answer)
4.8/5
(38)

You should make a function a virtual function if

(Multiple Choice)
4.9/5
(37)

In the derived class definition,you list from the base class

(Multiple Choice)
4.9/5
(43)

Using virtual functions is also known as _______ the functions

(Short Answer)
4.8/5
(37)

A derived class pointer can point to

(Short Answer)
4.7/5
(38)

Given the following classes and code,what is the output of the last statement shown? Class Pet { Public: Virtual void print); String name; Private: }; Class Dog: public Pet { Public: Void print); String breed; }; Void Pet::print) { Cout << "My name is " << name; } Void Dog::print) { Pet::print); Cout << ",and my breed is a "<< breed << endl; } Pet* pPtr; Dog* dPtr=new Dog; DPtr->name= "Rover"; DPtr->breed="Weiner"; PPtr= dPtr; PPtr->print);

(Multiple Choice)
4.8/5
(40)

Member functions defined as private in the base class are/are not)inherited in the derived class

(Short Answer)
4.8/5
(41)

Another name for the base class is

(Multiple Choice)
4.8/5
(36)

A base class pointer variable can point to

(Short Answer)
4.9/5
(48)
Showing 21 - 40 of 53
close modal

Filters

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