Question: QUESTION 64 Assume the following: class test { private: int x, y; public: int sum(); //returns the sum of the private data members void print();

QUESTION 64

Assume the following:

class test { private: int x, y; public: int sum(); //returns the sum of the private data members void print(); //prints the values of the private data members: // the x value followed by the y value test(); //initializes the private data members to 0 test(int, int); //initializes the private data members to the passed in values: // x = value of the first argument // y = value of the second argument }; int main() { test t1 = test(); test t2 = test( 240, 360 ); }

Which of the following lines of code will create an object with the value 465 for y and 0 for x?

a.

test t3 = test( , 465 );

b.

test t3 = test( 465, 0 );

c.

test t3 = test( 0, 465 );

d.

test t3 = test( 465 );

1 points

QUESTION 65

A function is to a standard C++ program as a __________ is to an object oriented program.

a.

method

b.

object

c.

variable

d.

thing

1 points

QUESTION 66

I define all my data members in a class to be private so the user of my class can not see their names. What is this an example of?

a.

constructor hiding

b.

data hiding

c.

encapsulation

d.

set methods

1 points

QUESTION 67

Assume the following:

class Time { public: Time( int, int, int ); //Initializes a Time object void setHour( int ); //Set hour data member to a value between 1 and 12 void setMinute( int ); //Set minute data member to a value between 0 and 59 void setSecond( int ); //Set second data member to a value between 0 and 59 int getHour(); //Returns the contents of the hour data member int getMinute(); //Returns the contents of the minute data member int getSecond(); //Returns the contents of the second data member void printTime(); //Prints the contents of a Time object (hour:minute:second) private: int hour, minute, second; };

Which of the following lines of code will display/print ONLY the hour value for an instance of the Time class named time1?

a.

time1.printTime();

b.

cout << time1.getHour();

c.

cout << time1.hour;

d.

time1.getHour();

1 points

QUESTION 68

One should use a class over a structure if the class has many data members and many methods in its design, and security is a top priority.

True

False

1 points

QUESTION 69

string Student::getFirstName() { return firstName; }

This is an example of a function overload. True or False

a.

true

b.

false

1 points

QUESTION 70

A class may have multiple constructors as long as each one has a different name.

True

False

1 points

QUESTION 71

Assume the following:

class Complex { public: Complex(int, int); //initializes the private data members to the passed in values: // real = value of the first argument // imag = value of the second argument Complex add( Complex ); //returns a Complex object that holds the sum of two //Complex objects void print(); //prints the values of the private data members in the format: // (real, imag) private: int real, imag; };

Which of the following is a valid implementation of the print method?

a.

void Complex::print() { Complex c; cout << ( << c.real << , << c.imag << ) << endl; }

b.

void Complex::print() { cout << ( << real << , << imag << ) << endl; }

c.

void print() { Complex c; cout << ( << c.real << , << c.imag << ) << endl; }

1 points

QUESTION 72

Assume the following:

class Time { public: Time( int, int, int ); //Initializes a Time object void setHour( int ); //Set hour data member to a value between 1 and 12 void setMinute( int ); //Set minute data member to a value between 0 and 59 void setSecond( int ); //Set second data member to a value between 0 and 59 int getHour(); //Returns the contents of the hour data member int getMinute(); //Returns the contents of the minute data member int getSecond(); //Returns the contents of the second data member void printTime(); //Prints the contents of a Time object (hour:minute:second) private: int hour, minute, second; };

Which of the following lines of code will create an instance of the Time class called time1. It should have an initial time with the hour value of 10, minute value of 3, and second value of 28?

a.

Time time1;

b.

Time time1 = Time;

c.

Time time1 = { 10, 3, 28 };

d.

Time time1( 10, 3, 28 );

1 points

QUESTION 73

Assume the following:

class test { private: int x, y; public: int sum(); //returns the sum of the private data members void print(); //prints the values of the private data members: // the x value followed by the y value test(); //code initializes the private data members to 0 test(int, int); //initializes the private data members to the passed in values: // x = value of the first argument // y = value of the second argument }; int main() { test t1 = test(); test t2 = test( 240, 360 ); }

What output will be produced by the following line of code? t1.print();

a.

0 0

b.

240 360

c.

garbage values because no values were passed in when object t1 was created

d.

nothing

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!