C++: Final Study Guide

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

To overload a member function of the base class, the name of the function and the formal parameter list of the corresponding function in the derived class must be same.

F

____ is the ability to use the same expression to denote different operations

Inheritance - WRONG Polymorphism

The ____ members form the internal object state

Protected - WRONG Private

If inheritance is private, all members of the base class, including private members, become private members of the derived class.

F

In a problem description, some of the nouns would become classes and some would become operations.

F

In composition, all members belong to the same class.

F

In the case of composition, you use the class name to invoke the base class's constructor

F

OOP means objects of programming.

F

Redefining a function of a base class is also known as overloading a function.

F

Single inheritance means that only one class can be derived from the given base class.

F

The class io is the base class of the C++ stream classes istream and ostream.

F

The constructor of a derived class can directly access the private data members of the base class.

F

#include <iostream> using namespace std; class bClass { public: void print() const; bClass(int a = 0, int b = 0); //Postcondition: x = a; y = b; private: int x; int y; }; class dClass: public bClass { public: void print() const; dClass(int a = 0, int b = 0, int c = 0); //Postcondition: x = a; y = b; z = c; private: int z; }; int main() { bClass bObject(2, 3); dClass dObject(3, 5, 8); bObject.print(); cout << endl; dObject.print(); cout << endl; return 0 ; } void bClass::print() const { cout << x << " " << y << endl; } bClass:: bClass(int a, int b) { x = a; y = b; } void dClass::print() const { bClass:print(); cout << " " << z << endl; } dClass:: dClass(int a, int b, int c) : bClass(a, b) { z = c; }

3 5 8 3 5 8 - WRONG 2 3 3 5 8

Which of the following is true about a derived class?

A derived class can redefine any public member function of the base class.

The constructor of a derived class specifies a call to the constructor of a base class in the body of the function definition.

F

The earliest OOP language was Smalltalk, developed in 1967.

F

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

F

____ is the ability to combine data, and operations on that data, in a single unit

Encapsulation

A derived class and its base class cannot have member functions with the same name.

F

A derived class can directly access any member of the base class.

F

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

F

An OOD implements OOP.

F

Composition is a "one-to-one" relation.

F

A derived class can directly access the protected members of the base class

T

A derived class can redefine a public member function of the base class

T

C++ supports both single and multiple inheritance.

T

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

T

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.

T

In multiple inheritance, the derived class has more than one base class.

T

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

T

OOD allows ADTs to be created and used.

T

OOD means object-oriented design

T

Only the object can manipulate its internal state.

T

The constructor of a derived class specifies a call to the constructor of the base class using the name of the base class

T

The constructors of a derived class cannot directly initialize any members inherited from the base class of the derived class

T

The preprocessor directive #ifndef is used to prevent multiple inclusions of a header file in a program

T

Which of the following is true about inheritance? a. All public members of the base class become the public members of the derived class. b. All public member functions of the base class become the public member functions of the derived class c. All public member variables of the base class become the public member variables of the derived class. d. The public member variables of the base class become the public or private member variables of the derived class.

The public member variables of the base class become the public or private member variables of the derived class.

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

The public members of the base class become protected members of the derived class.

The existing classes, from which you create new classes, are called the ____ classes.

base

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

class aClass: public bClass { //... }; WRONG class aClass: bClass { //... }; WRONG class bClass: public aClass { //... };

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

class bClass: public aClass { //... };

Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass?

class dClass:: public bClass { //classMembersList }; WRONG class bClass: public dClass { //classMembersList }; WRONG class dClass:: protected bClass { //classMembersList }; WRONG class dClass: private bClass { //classMembersList };

If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class you use the ____ statement.

classB.functionName(); -WRONG classB::functionName();

_______ is a "has-a" relationship

compostion

Which of the following dClass constructor definitions is valid in C++?

dClass::dClass(double a, double b, double c) : bClass(a, b) { z = c; }

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

derived

____ is an "is-a" relationship

inheritance

Inheritance is an example of what type of relationship?

is-a

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.

overload - WRONG redefine

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.

overridden - WRONG overloaded

The ____ members form the external object state

public

Consider the following class definition. class dClass: bClass { //class members list }; The class dClass is derived from the class bClass using the ____ type of inheritance

static - WRONG public - WRONG protected - WRONG Private

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

virtual

Which of the following statements correctly redefines the member function print of bClass?

void dClass::print() const { dClass:print(); cout << " " << y << endl; } WRONG void dClass::print() const { cout << x << " " << y << endl; } WRONG void bClass::print() const { cout << x << " " << y << endl; } WRONG void dClass::print() const { bClass::print(); cout << "y = " << y << endl; }

Which of the following correctly sets the values of x and y?

void dClass::setXY(int a, int b) { x = bClass.setX(a); b = y; } WRONG void dClass::setXY(int a, int b) { bClass::setX(a); y = b; }


Kaugnay na mga set ng pag-aaral

Chapter 15: Accounting for Stockholders' Equityretained earnings

View Set

Basic Research and Applied Research: Definitions and Differences (Chapter 16)

View Set