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

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

 

Week 4 : Midterm Exam 1

Multiple Choice Questions

1. (TCO 1) What is the output of the following C++ code?

int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 1; j <= 5; j++) cout << list[j]; (Points : 4) 1. 0 5 10 15 20 2. 5 10 15 20 0 3. 5 10 15 20 20 4. Code contains index out of bounds 2. (TCO 1) What is the value of alpha[4] after the following code executes? int alpha[5] = {0}; int j; alpha[0] = 2; for (j = 1; j < 5; j++) alpha[j] = alpha[j - 1] + 3; (Points : 4) 1. 5 2. 8 3. 11 4. 14 3. (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] = j + 1; if (j > 2)
alpha[j – 1] = alpha[j] + 2;
} (Points : 4)
1. alpha = {1, 2, 6, 7, 5}
2. alpha = {1, 2, 3, 4, 5}
3. alpha = {4, 5, 6, 7, 9}
4. None of these

4. (TCO 1) Which of the following about arrays as function parameters is true?
(i) Arrays are passed by reference only.
(ii) When we declare an array as a formal parameter we do not attach & after the data type of the array component. (Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these

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) Consider the statement:
int list[10][8];
Which statement about list is true? (Points : 4)
1. list has 10 rows and eight columns.
2. list has eight rows and 10 columns.
3. list has a total of 18 components.
4. list has a total of 108 components.

7. (TCO 1) Consider the following statements.
int alpha[10][5] = {0};
int j,k;
Which of the following statements correctly initializes alpha to 0?

(i)
for (j = 0; j < 10; j++) for(k = 0; k < 5; k++) alpha[j][k] = 0; (ii) for (k = 0; k < 5; k++) for (j = 0; j < 10; j++) alpha[j][k] = 0; (Points : 4) 1. Only (i) 2. Only (ii) 3. Both (i) and (ii) 4. None of these 8. (TCO 1) Considering the following statement: double alpha[10][5]; what is the last row and column element of the array? (Points : 4) 1. alpha[10][5] 2. alpha[9][4] 3. alpha[10][4] 4. alpha[9][5] 9. (TCO 2) The member variables of a class (Points : 4) 1. must be of the same data type. 2. must be in the same section--either public or private. 3. can be any data type. 4. must be initialized in the class definition. 10. (TCO 2) A class and its members can be described graphically by using (Points : 4) 1. Unified Modeling Language (UML) notation. 2. a flowchart. 3. Unified Abstract Language (UAL) notation. 4. Unified Encapsulation Language (UEL) notation. Page 2 Multiple Choice 1. (TCO 2) Given the declaration: class myClass { public: void print(); int y; private: int x; }; myClass myObject; which statement is legal? (Points : 4) 1. myObject.x = 10; 2. myClass.x = 10; 3. myObject.y = 10; 4. myClass.y = 10; 2. (TCO 2) The components of a class are called the _____ of the class. (Points : 4) 1. elements 2. members 3. objects 4. properties 3. (TCO 2) Suppose that you have the following UML class diagram of a class. According to the UML class diagram, which function is public and doesn't return anything? (Points : 4) 1. incrementHours 2. equalTime 3. printTime 4. setTime 4. (TCO 2) A _____ sign in front of a member name on the UML diagram indicates that this member is private. (Points : 4) 1. + 2. - 3. # 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; }; and the declaration rectangleType bigRect; Which of the following statements is correct? (Points : 4) 1. rectangleType.print(); 2. rectangleType::print(); 3. bigRect.print(); 4. bigRect::print(); 6. (TCO 3) Composition, like inheritance, demonstrates what software development advantage of object-oriented programming? (Points : 4) 1. Better coordination between software developers 2. Reduced development time 3. Reusable code 4. All of the above 7. (TCO 8) Which preprocessor directive is used to end a conditional compilation directive? (Points : 4) 1. define 2. ifndef 3. ifdef 4. endif 8. (TCO 8) What is a preprocessor directive? (Points : 4) 1. An instruction to the preprocessor 2. An instruction to the linker 3. An instruction to the debugger 4. An instruction to the compiler 9. (TCO 8) What is the namespace commonly used with ? (Points : 4)
1. std
2. standard
3. .h
4. cin and cout

10. (TCO 8) Which preprocessor directive is not used for conditional compilation? (Points : 4)
1. define
2. ifndef
3. ifdef
4. endif

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)
1. static
2. automatic
3. local
4. public

2. (TCO 3) Composition and inheritance are two fundamental ways of relating _____. (Points : 4)
1. classes
2. objects
3. class function members
4. class data members

3. (TCO 4) The private members of a base class can (Points : 4)
1. never be accessed by a derived class.
2. be directly and indirectly accessed by a derived class.
3. be indirectly accessed by a derived class.
4. be directly accessed by a derived class.

4. (TCO 4) To overload a member function of the base class (Points : 4)
1. the name of the function and the formal parameter list of the corresponding function in the derived class must be the same.
2. the name of the function must be different and the formal parameter list of the corresponding function in the derived class must be the same.
3. the name of the function and the formal parameter list of the corresponding function in the derived class must be different.
4. the name of the function must be the same and the formal parameter list of the corresponding function in the derived class must be different.

5. (TCO 4) Which of the following class definitions makes the public members of the class aClass become the public members of the class bClass? (Points : 4)
1. class aClass: public bClass{ //…};
2. class bClass: public aClass{ //…};
3. class bClass: aClass{ //…};
4. class aClass: bClass{ //…};

6. (TCO 4) _____ is the ability to combine data, and operations on those data, in a single unit. (Points : 4)
1. Inheritance
2. Encapsulation
3. Polymorphism
4. Composition

7. (TCO 4) If class AClass is derived from class BClass, which one of the following statements correctly states the constructor call sequence when an object of AClass is instantiated? (Points : 4)
1. BClass constructor first, AClass constructor second
2. AClass constructor first, BClass constructor second
3. BClass constructor only; the AClass constructor is not called if AClass derived private from BClass
4. AClass constructor only; the BClass constructor is not called if BClass derived private from AClass

8. (TCO 4) Which one of the following statements is a correct example of inheritance? (Points : 4)
1. An automobile has an engine.
2. An automobile is a Mustang.
3. A Mustang is an automobile.
4. An engine is part of an automobile.

9. (TCO 4) Which of the following statements does not correctly describe inheritance? (Points : 4)
1. Going from a general description to a more specific description
2. Describes an “is a” relationship
3. Describes a “has a” relationship
4. Allows for reusable code

10. (TCO 8) In a multifile, object-oriented C++ project, which file contains the class implementation? (Points : 4)
1. classname.hdr
2. classname.h
3. classname.def
4. classname.cpp

Essay Type
1. (TCO 1) Explain how to use loops to process data stored in a two-dimensional array. In your explanation include a two-dimensional array declaration and initialization. (Points : 10)

2. (TCO 1) Given a two-dimensional array named number of three rows and four columns of type int, write the single code statement that will both declare and initialize the array such that the first row is initialized to 0, 1, 2, 3; the second row is initialized to 4, 5, 6, 7; and the third row is initialized to 8, 9, 10, 11. (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) Discuss what the difference is between an interface file and an implementation file and provide file name examples for both if a class Insect is to be created using them. (Points : 10)
5. (TCO 3) Assume that a definition of class Automobile has two composite objects called myEngine of class Engine and myTransmission of class Transmission. If an object of Automobile is instantiated and then goes out of scope, list the sequence in which all constructors and destructors are called. Also, provide the explanation for why they are called in this sequence. (Points : 10)

6. (TCO 4) Explain what a base class access specifier is and how it affects inheritance. (Points : 10)

7. (TCO 4) If a class is derived protected 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)

8. (TCO 8) Why are comments and comment blocks important to programming? (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=”181″]
Please feel free to send us your queries at: support@iqrajavaid.com

Leave a Reply