Ch. 11 Object-Oriented Programming: Inheritance

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The is-a relationship represents.

Inheritance.

Assuming the following is the beginning of the constructor definition for class Circle which inherits from class Point, Circle::Circle( double r, int a, int b ) : Point( a, b ) The second line:

Invokes the Point constructor with values a and b.

Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class?

All of the above are disadvantages of the "copy-and-paste" approach.

Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class?

All of these are disadvantages of the "copy-and-paste" approach.

Assuming the definition, class Circle : public Point which of the following is false?

All the public and protected members of class Circle are inherited as public and protected members, respectively, into class Point.

Base class constructors and assignment operators:

Are not inherited by derived classes.

Suppose class A inherits from base class B. What is the order in which their constructors and destructors will be called when an object of class A is instantiated and then destroyed?

B constructor, A constructor, A destructor, B destructor.

When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.

Base class, base class.

Select the false statement regarding inheritance.

Base classes are usually more specific than derived classes.

Which of the following is true about using inheritance in software engineering?

Common attributes and behaviors should be factored out of closely related classes and placed into a base class from which the original classes can now inherit.

protected base class members cannot be accessed by:

Functions that are neither friends of the base class, derived-class member functions nor friends of a derived class.

Which of the following statements about inheriting base class constructors is false?

If an inherited base-class constructor has default arguments, the line of code in Part (a) causes the compiler to generate a derived-class constructor with the same default arguments.

Which forms of inheritance are is-a relationships?

Only public.

Which of the following is not a good example of a hierarchy that could be modeled by inheritance?

Prime numbers.

Theoretically, clients do not need to see the ________ of classes from which they derive other classes.

Source code.

When should base class members be declared protected?

When these members should be available only to derived classes (and friends), not to other clients.

Which of the following is most likely a base class of the other three?

automobile.

To declare class subClass a privately derived class of superClass one would write:

class subclass : private superClass.

From most restrictive to least restrictive, the access modifiers are:

private, protected, public

When deriving a class from a protected base class, the public members of the base class become ________ and the protected members of the base class become ________?

protected, protected

When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________?

protected, protected.

Which of the following is not a kind of inheritance in C++?

static.


संबंधित स्टडी सेट्स

Real Estate 101- Promulgated Contract Forms

View Set

federal government mind tap wrap it up unit 1

View Set

240 Chapter 39: Oxygenation and Perfusion

View Set