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

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.

a.

static

b.

private

c.

protected

d.

public

1 points

QUESTION 2

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

a.

class dClass:: public bClass { //classMembersList };

b.

class dClass: private bClass { //classMembersList };

c.

class bClass: public dClass { //classMembersList };

d.

class dClass:: protected bClass { //classMembersList };

1 points

QUESTION 3

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

a.

Inheritance

b.

Composition

c.

Polymorphism

d.

Encapsulation

1 points

QUESTION 4

What is the output of the following program?

#include 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; }

a.

2 3

2 3

b.

2 3

3 5 8

c.

3 5 8

3 5 8

d.

5 8

3 5 8

1 points

QUESTION 5

Consider the following class definitions: class bClass { public: void set(double a, double b); //Postcondition: x = a; y = b; void print() const; bClass(); //Postcondition: x = 0; y = 0; bClass(double a, double b); //Postcondition: x = a; y = b; private: double x; double y; }; class dClass: public bClass { public: void set(double a, double b, double c); //Postcondition: x = a; y = b; z = c; void print() const; dClass(); //Postcondition: x = 0; y = 0; z = 0 ; dClass(double a, double b, double c); //Postcondition: x = a; y = b; z = c; private: double z; }; Which of the following dClass constructor definitions is valid in C++?

a.

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

b.

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

c.

dClass::dClass(double a, double b) : bClass() { x = a; y = b; }

d.

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!