Page 1
Multiple Choice
1. (TCO 1) Which of the following about C++ arrays is true?
(i) Array components must be of type double.
(ii) The array index must be of an integral type. (Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these
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) Consider the statement:
int list[10][8];
Which statement about list is true? (Points : 4)
List has 10 rows and 8 columns.
List has 8 rows and 10 columns.
List has a total of 18 components.
List has a total of 108 components.
6. (TCO 1) After the following statements execute, what are the contents of matrix?
int matrix[4][3] = {0};
int j, k;
for (j = 0; j < 4; j++)
for (k = 0; k < 3; k++)
matrix[j][k] = 2 * j + k;
(Points : 4)
0 2 4
1 3 5
2 4 6
3 5 7
0 1 2
1 2 3
2 3 4
3 4 5
0 2 4
2 4 6
4 6 8
6 8 10
0 1 2
2 3 4
4 5 6
6 7 8
7. (TCO 1) Consider the following statement:
double alpha[10][5];
What is the last row and column element of the array? (Points : 4)
alpha[10][5]
alpha[9][4]
alpha[10][4]
alpha[9][5]
8. (TCO 2) A class is an example of a (Points : 4)
structured data type.
unstructured data type.
simple data type.
primitive data.
9. (TCO 2) In C++ terminology, (Points : 4)
a class object is the same as a class instance.
a class object is the same as a class member.
a class object is the same as a class access specifier.
a class object is the same as a non-member function.
10. (TCO 2) In C++, the mechanism that allows you to combine data and the operations on that data in a single unit is called a(n) ____. (Points : 4)
enumeration
class
member
struct
11. (TCO 4) To overload a member function of the base class, (Points : 4)
the name of the function and the formal parameter list of the corresponding function in the derived class must be same.
the name of the function must be different and the formal parameter list of the corresponding function in the derived class must be same.
the name of the function and the formal parameter list of the corresponding function in the derived class must be different.
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.
12. (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};
13. (TCO 5) Given a class called Employee and the following definitions and statements:
void myFunction( Employee * eptr );
Employee emp;
which of the following statements correctly calls the function passing in the address of the emp object?
(Points : 4)
myFunction(emp);
myFunction(&emp);
myFunction(*emp);
None of the above
Page 4
Essay Questions
1. (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 handheld 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)
2. (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)
3. (TCO 2) Explain the difference between a parameterized constructor and a default constructor. Provide an example class that includes both types of constructors. (Points : 10)
4. (TCO 4) If a class is derived public 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)
5. (TCO 5) When dynamically allocating memory for a specific data type, explain why a pointer variable of the same data type must be used. Describe what happens if the memory allocation is successful and also if it is unsuccessful. (Points : 10)
6. (TCO 6) Explain why the native operators defined in C++ will not work with classes unless they have been properly overloaded. (Points : 10)
7. (TCO 7) Discuss run-time binding and how it relates to virtual functions. (Points : 10)
8. (TCO 8) Describe what a namespace is and provide general syntax of a namespace statement. (Points : 10)
* If you have any issues with the payment method, please let us know at [email protected] 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 [email protected].
* 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 [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please expect a response within 8 hours 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 [email protected].
******************************************** Good Luck ***************************************************