COMP220 Solved Midterm Exam – Week 4 – Previous Exam – Guaranteed 100% score

Exam Price = $19
[orb_cyber_store id=”183″]
Please feel free to send us your queries at: support@iqrajavaid.com
Problem Statement

 

Week 4 : Object Composition – Midterm Exam 3

1. (TCO 1) Assume you have the following declaration:
char nameList[100];
which of the following ranges is valid for the index of the array nameList? (Points : 4)
0 through 99
0 through 100
1 through 100
1 through 101

2. (TCO 1) What is stored in alpha after the following code executes?

int alpha[5] = {0};
int j;
for (j = 0; j < 5; j++) { alpha[j] = 2 * j; if (j % 2 == 1) //see if j is an even number alpha[j - 1] = alpha[j] + j; } (Points : 4) alpha = {0, 2, 4, 6, 8} alpha = {0, 2, 9, 6, 8} alpha = {0, 3, 4, 7, 8} alpha = {3, 2, 9, 6, 8} 3. (TCO 1) What is the value of alpha[3] after the following code executes? int alpha[6] = {0}; int j; for(j = 4; j >= 0; j–)
{
alpha[j] = j + 5;
if (j % 2 == 0)
alpha[j + 1] = alpha[j] + 3;
} (Points : 4)
5
8
9
10

4. (TCO 1) Consider the following declaration:
int alpha[3];
Which of the following input statements correctly inputs values into all the array elements of alpha? (Points : 4)
cin >> alpha >> alpha >> alpha;
cin >> alpha[0] >> alpha[1] >> alpha[2];
cin >> alpha[1] >> alpha[2] >> alpha[3];
cin >> alpha

5. (TCO 1) Given the function prototype void strange(int a, int b);
And the following declaration,
int alpha[10];
int beta[10];
Which of the following is a valid call to the function strange? (Points : 4)
strange(alpha[0], alpha[1]);
strange(alpha, beta);
strange(alpha[0], beta);
strange(alpha, beta[0]);

6. (TCO 1) After the following statements execute, what are the contents of matrix?

int matrix[3][2] = {0};
int j, k;
for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) matrix[j][k] = j + k; (Points : 4) 0 0, 1 1, 2 2 0 1, 2 3, 4 5 0 1, 1 2, 2 3 1 1, 2 2, 3 3 7. (TCO 1) Consider the following statements. int beta[10][5] = {0}; int j, k; Which of the following statements correctly outputs the elements of beta one row per line? (i) for (j = 0; j < 10; j++) { for (k = 0; k < 5; k++) cout << beta[j][k]; cout << endl; } (ii) for (j = 0; j < 10; j++) for (k = 0; k < 5; k++) { cout << beta[j][k]; cout << endl; } (Points : 4) Only (i) Only (ii) Both (i) and (ii) None of these 8. (TCO 1) Given the following multidimensional array declaration, how many elements exist in the array? double neoMatrix[4][5][6]; (Points : 4) 456 60 15 120 9. (TCO 2) In C++, class is a reserved word that defines (Points : 4) a data type. an object type. a variable. an enumeration. 10. (TCO 2) The member functions of a class should usually be (Points : 4) public. private. protected. templates. Page 2 Multiple Choice 1. (TCO 2) If the heading of a member function of a class ends with the word const, then (Points : 4) the function members cannot modify the private member variables, but can modify the public member variables. the function members cannot modify the public member variables, but can modify the private member variables. the function members cannot modify the private member variables, nor can they modify the public member variables. all variables can be modified. 2. (TCO 2) Given the declaration: class myClass { public: void print(); private: int x; }; myClass myObject; which statement is legal? (Points : 4) myObject.print = 10; myClass.print = 10; myObject.print(); myClass.print(); 3. (TCO 2) Given: bool clockType::equalTime(const clockType&) const {...} void clockType::getTime(int&, int&, int&) const {...} The word _____ at the end of the member functions in the class clockType specifies that these functions cannot modify the member variables of a clockType object. (Points : 4) void const clockType:: & 4. (TCO 2) A _____ sign in front of a member name on the UML diagram indicates that this member is public. (Points : 4) + - # $ 5. (TCO 2) Consider the following class definition: class rectangleType { public: void setLengthWidth(double x, double y); //Postcondition: length = x; width = y; void print() const; //Output length and width; double area(); //Calculate and return the area of the rectangle; double perimeter(); //Calculate and return the parameter; rectangleType(); //Postcondition: length = 0; width = 0; rectangleType(double x, double y); //Postcondition: length = x; width = y; private: double length; double width; }; Which of the following class variable declarations is correct? (Points : 4) rectangle rectangleType; class rectangleType rectangle; rectangleType rectangle; rectangle rectangleType.area; 6. (TCO 3) A(n) _____ relationship represents composition. (Points : 4) "has a" "is a" "part of" logical 7. (TCO 8) If a Class A has an object of Class B as a data member, what type of function must be used for an object of Class A to obtain a copy of a private data member of Class B? (Points : 4) Class B copy constructor Class B accessor function Class A accessor function It is not possible for an object of Class A to do this action. 8. (TCO 8) Which is a correct preprocessor directive statement? (Points : 4) define PI = 3.141593 define PI = 3.141593; #define PI 3.141593 #define PI = 3.141593 9. (TCO 8) Which is a correct preprocessor directive statement? (Points : 4) define PI = 3.141593 define PI = 3.141593; #define PI 3.141593 #define PI = 3.141593 10. (TCO 8) Which one of the commonly used include (header) files is not covered by the std namespace? (Points : 4) math iomanip string iostream Page: 1 2 3 4 Time Remaining:   Week 4 : Object Composition - Midterm Exam Time Remaining: Page: 1 2 3 4 Page 3 Multiple Choice 1. (TCO 2) A class object can be _____. That is, it can be created once, when the control reaches its declaration, and destroyed when the program terminates. (Points : 4) static automatic local public 2. (TCO 3) Which of the following statements is an accurate example of composition? (Points : 4) A car has an engine. A car is an automobile. A car is an object. A car has a class. 3. (TCO 4) A derived class (Points : 4) can never access public members of a base class. can directly access public members of a base class. cannot change the value of public members of a base class. can only directly access private members of the base class. 4. (TCO 4) If inheritance is private (Points : 4) public and protected members of the base class become private members of the derived class. all private members of the base class become public members of the derived class. protected members of the base class become public members of the derived class. none of the members of the base class become members of the derived class. 5. (TCO 4) Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass? (Points : 4) class dClass:: public bClass{ //classMembersList}; class dClass: private bClass{ //classMembersList}; class dClass:: protected bClass{ //classMembersList}; class bClass: public dClass{ //classMembersList}; 6. (TCO 4) OOP implements _____. (Points : 4) UML IPE EIP OOD 7. (TCO 4) 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. (Points : 4) public private protected static 8. (TCO 4) Which of the following base class members is never inherited by a derived class, regardless of access attributes? (Points : 4) Mutator Accessor Constructor Data 9. (TCO 4) Which of the following statements correctly describes an example of multiple inheritance? (Points : 4) Mother and Father to Children Animal to Reptile to Snake Parent to Child Animal to Mammal and Bird 10. (TCO 8) In a multifile, object-oriented C++ project, which file contains the class definition? (Points : 4) classname.cpp classname.h classname.def classname.hdr Page: 1 2 3 4 Time Remaining: 1. (TCO 1) Describe the conceptual model of a two-dimensional array. Include in your explanation how a two-dimensional array might be used, why these arrays are similar to tables, and how to declare and initialize a two-dimensional array. 2. (TCO 1) Describe an example of a two-dimensional character array that could be used to hold a set of text data that might be displayed on a hand-held information display device such as an MP3 player. Describe what each of the two dimensions might represent and the data that would be held in the array, and provide an example array declaration. (Points : 10) 3. (TCO 2) Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constructors. (Points : 10) 4. (TCO 2) Describe in detail what is contained in each of three areas of a Unified Modeling Language (UML) diagram of a class. (Points : 10) 5. (TCO 3) Using a personal computer as a base model, write a C++, syntactically correct class definition demonstrating composition. In the class definition include at least the three following items common to a PC: a CD drive, a hard disk drive, and a power supply. You are not required to include any constructors,destructors, or additional member functions. You are only required to list members that directly show composition and proper access attributes. (Points : 10) 6. (TCO 4) Explain how access privileges affect members of the derived class and the objects created from them. (Points : 10) 7. (TCO 4) If a class is derived private from a base class, explain how this affects the inheritance of all public, protected, and private members of the base class by the derived class. (Points : 10) If a class is derived private from a base class then, 1. All public members of a base class become private in a derived class 2. All protected members of a base class become private in a derived class 3. All private members of a base class remain private in a derived class. 8. (TCO 8) Describe what a namespace is and provide general syntax of a namespace statement. (Points : 10)

Relevant Material
Instructions
* Please click on “Buy Now” button to complete the purchase.Please note that the payment is done through PayPal.
* If you have any issues with the payment method, please let us know at support@iqrajavaid.com and that can be discussed and considered.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at support@iqrajavaid.com.
* As soon as the payment is received through PayPal, download link of the solution will automatically be sent to the address used in Paypal.
* Please check your junk mails as the download link email might go there.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at support@iqrajavaid.com and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at support@iqrajavaid.com.

******************************************** Good Luck ***************************************************

Privacy Policy
We take your privacy seriously and will take all measures to protect your personal information.
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
Refund Policy
Incase you face any issues with the tutorial, please free to contact us on support@iqrajavaid.com
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.
Payment Details
Exam Price = $19
[orb_cyber_store id=”183″]
Please feel free to send us your queries at: support@iqrajavaid.com

Leave a Reply