Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1... How many times will the Bird class default constructor be called in the fol

ID: 3877015 • Letter: 1

Question

1...

How many times will the Bird class default constructor be called in the following declarations:

Bird Parrot[5];

Select one:

a. 0

b. 1

c. 5

d. 6

2...

Which of the follow will NOT cause double change = 0; to output “0.00”?

Select one:

a. cout << fixed << setprecision(2) << change;

b. cout << setprecision(3) << change;

c. cout << showpoint << setprecision(3) << change;

d. All of the above cause output to be “0.00”.

3....

What is the output of the last cout statement in the following code, assuming the user first enters “Travis” then presses enter, then enters “The grass is always greener” then presses enter.

int main() {

   string name;

   string favQuote;

   cout << "Enter your name: ";

   getline(cin, name);

   cout << "Enter your favorite quote: ";

   cin >> favQuote;

   cout << name << " likes the quote: " << favQuote;

   return 0;

}

Select one:

a. Travis likes the quote: The

b. Travis likes the quote: The grass is always greener

c. The grass is always greener likes the quote: Travis

d. No output. Error in code.

4.....

Which of the following is the declaration of a vector called person of type height which is a struct with two integer data members ft and in?

Select one:

a. vector<height> person;

b. vector<height(int ft, int in)> person;

c. vector<height<int, int>> person;

d. height<vector<int,int>> person;

5...

Which of the following declares a variable person of struct type height?

Select one:

a. person height;

b. height person;

c. height<person>;

d. struct person height;

6....

Which of the following defines the default constructor for the class Schedule?

Select one:

a. Schedule::Schedule() { /* Function code */ }

b. void Schedule() { /* Function code */ }

c. Schedule->Schedule() { /* Function code */ }

d. Schedule() { /* Function code */ }

7....

Which preprocessor directive prevents a file from being included multiple times?

Select one:

a. #ifndef

b. #include

c. #define

d. #guard

8...

Which of the following lines contains a syntax error?

int main() {

   ostringstream ageOSS;

   int myAge = 22;

   ageOSS << “I am “ << myAge << “ years old.”;

   cout << ageOSS.str();

   return 0;

}

Select one:

a. ostringstream ageOSS;

b. ageOSS << “I am “ << myAge << “ years old.”;

c. cout << ageOSS.str();

d. None of the above.

9....

What is the output of the following code given the program was called using the command-line:

a.out infile.txt outfile.txt auxfile.dat

int main(int argc, char* argv[]) {

   cout << argv[2];

   return 0;

}

Select one:

a. infile.txt

b. outfile.txt

c. infile.txt outfile.txt auxfile.dat

d. None of the above.

10.....

Which of the following will attempt to open the file “output_file.txt” stored in the string myfile using the ofstream outFS?

Select one:

a. ofstream.open(“output_file.txt”);

b. outFS.open(myfile.c_str());

c. myfile.open(outFS);

d. outFS.open(output_file.txt);

Explanation / Answer

1. d. 6

It is called for 6 times as we have given 5 in the argument. Default constructor is called every time an object is initialized. Here the bird class calles for 6 times and the default constructor is also called 6 times.

2. d. All of the above cause output to be “0.00”.

3. b. b. Travis likes the quote: The grass is always greener

4. a. a. vector<height> person;

5. b. height person;

6. a. a. Schedule::Schedule() { /* Function code */ }

7. a. a. #ifndef

8. d. d. None of the above

9. d. d. None of the above

10. d. d. outFS.open(output_file.txt);