Filters
Question type

Study Flashcards

A call to the base class's constructor is specified in the heading of the definition of a derived class constructor.

A) True
B) False

Correct Answer

verifed

verified

In protected inheritance, public and protected members of the base class become the protected members of the derived class.

A) True
B) False

Correct Answer

verifed

verified

Which of the following class definitions makes the public members of the class aClass become the public members of the class bClass?


A) class aClass: public bClass
{
//) ..
};
B) class bClass: public aClass
{
//) ..
};
C) class bClass: aClass
{
//) ..
};
D) class aClass: bClass
{
//) ..
};

E) All of the above
F) C) and D)

Correct Answer

verifed

verified

Consider the following class definition: The class dClass is derived from the class bClass using the ____ type of inheritance. Consider the following class definition: The class dClass is derived from the class bClass using the ____ type of inheritance.   A)  public B)  private C)  protected D)  static


A) public
B) private
C) protected
D) static

E) B) and C)
F) B) and D)

Correct Answer

verifed

verified

To ____ a public member function of a base class in the derived class, the corresponding function in the derived class must have the same name, number, and types of parameters.


A) redefine
B) overload
C) rename
D) reuse

E) C) and D)
F) None of the above

Correct Answer

verifed

verified

A

Which of the following is true about a derived class?


A) A derived class can directly access any member variable of the base class.
B) A derived class can redefine any public member function of the base class.
C) A derived class can have at most one base class.
D) A derived class can redefine any member function of the base class.

E) A) and B)
F) C) and D)

Correct Answer

verifed

verified

Consider the following class definitions: Which of the following dClass constructor definitions is valid in C++? Consider the following class definitions: Which of the following dClass constructor definitions is valid in C++?   A)  dClass::dClass(double a, double b, double c)  : bClass()  { x= a; y = b; z = c; } B)  dClass::dClass(double a, double c)  { x = a; z = c; } C)  dClass::dClass(double a, double b)  : bClass()  { x = a; y = b; } D)  dClass::dClass(double a, double b, double c)  : bClass(a, b)  { z = c; }


A) dClass::dClass(double a, double b, double c)
: bClass()
{
x= a;
y = b;
z = c;
}
B) dClass::dClass(double a, double c)
{
x = a;
z = c;
}
C) dClass::dClass(double a, double b)
: bClass()
{
x = a;
y = b;
}
D) dClass::dClass(double a, double b, double c)
: bClass(a, b)
{
z = c;
}

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

The private members of a base class can be directly accessed by a derived class.

A) True
B) False

Correct Answer

verifed

verified

If the derived class does not override a public member function of the base class, you may specify a call to that public member function by using the name of the function and the appropriate parameter list.

A) True
B) False

Correct Answer

verifed

verified

If the corresponding functions in the base class and the derived class have the same name but different sets of parameters, then this function is ____ in the derived class.


A) reused
B) redefined
C) overloaded
D) overridden

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

Which of the following statements about inheritance is true if memberAccessSpecifier is protected?


A) The private members of the base class become protected members of the derived class.
B) The derived class can directly access any member of the base class.
C) The public members of the base class become protected members of the derived class.
D) The protected members of the base class become private members of the derived class.

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

If inheritance is public, all protected members of the base class are ____________________ members of the derived class.

Correct Answer

verifed

verified

Consider the following class definitions: Consider the following class definitions:   Which of the following statements correctly redefines the member function print of bClass? A)  void dClass::print()  const { DClass:print() ; Cout <<     << y << endl; } B)  void dClass::print()  const { Cout << x <<     << y << endl; } C)  void bClass::print()  const { Cout << x <<     << y << endl; } D)  void dClass::print()  const { BClass::print() ; Cout <<  y =   << y << endl; } Which of the following statements correctly redefines the member function print of bClass?


A) void dClass::print() const
{
DClass:print() ;
Cout << " " << y << endl;
}
B) void dClass::print() const
{
Cout << x << " " << y << endl;
}
C) void bClass::print() const
{
Cout << x << " " << y << endl;
}
D) void dClass::print() const
{
BClass::print() ;
Cout << "y = " << y << endl;
}

E) A) and C)
F) C) and D)

Correct Answer

verifed

verified

Which of the following is a valid definition of the derived class bClass?


A) class aClass: public bClass
{
//) ..
};
B) class bClass: public aClass
{
//) ..
};
C) class aClass::bClass
{
//) ..
};
D) class bClass::aClass
{
//) ..
}

E) B) and D)
F) A) and B)

Correct Answer

verifed

verified

The constructors of a derived class can (directly) initialize only the (public data) members inherited from the base class of the derived class.

A) True
B) False

Correct Answer

verifed

verified

The constructor of a derived class cannot directly access the ____________________ member variables of the base class.

Correct Answer

verifed

verified

A derived class cannot directly access public members of a base class.

A) True
B) False

Correct Answer

verifed

verified

False

The new classes that we create from existing classes are called ____ classes.


A) sibling
B) base
C) derived
D) parent

E) B) and C)
F) B) and D)

Correct Answer

verifed

verified

C++ provides ____ functions as a means to implement polymorphism in an inheritance hierarchy, which allows the run-time selection of appropriate member functions.


A) redefined
B) overridden
C) virtual
D) overloaded

E) None of the above
F) C) and D)

Correct Answer

verifed

verified

C

C++ provides ____________________ functions as a means to implement polymorphism in an inheritance hierarchy.

Correct Answer

verifed

verified

Showing 1 - 20 of 41

Related Exams

Show Answer