1. (TCO 1) Assume you have the following declaration. int beta[50]; Which of the
ID: 3558672 • Letter: 1
Question
1. (TCO 1) Assume you have the following declaration.
int beta[50];
Which of the following is a valid element of beta? (Points : 4)
beta['0']
beta['1']
beta[0]
beta[50]
Question 2. 2. (TCO 1) Suppose alpha is an array of 50 components. Which of the following about alpha is true?
(i) The base address of alpha is the address of alpha[0].
(ii) The base address of alpha is the address of alpha[1]. (Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these
Question 3. 3. (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
Question 4. 4. (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)
alpha = {1, 2, 6, 7, 5}
alpha = {1, 2, 3, 4, 5}
alpha = {4, 5, 6, 7, 9}
None of these
Question 5. 5. (TCO 1) What is the output of the following C++ code?
int alpha[5] = {2, 4, 6, 8, 10};
int j;
for (j = 4; j >= 0; j--)
cout << "alpha[" << j << "] = " << alpha[j] << endl; (Points : 4)
2 4 6 8 10
4 3 2 1 0
8 6 4 2 0
10 8 6 4 2
Question 6. 6. (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
Question 7. 7. (TCO 2) A class and its members can be described graphically by using _____. (Points : 4)
Unified Modeling Language (UML) notation
a flowchart
Unified Abstract Language (UAL) notation
Unified Encapsulation Language (UEL) notation
Question 8. 8. (TCO 2) If a member of a class is ____, you cannot access it outside the class. (Points : 4)
public
automatic
private
static
Question 9. 9. (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 consider this object declaration.
rectangleType bigRect(14,10);
Which of the following statements is correct? (Points : 4)
bigRect.setLengthWidth();
bigRect.setLengthWidth(3.0, 2.0);
bigRect.length = 2.0;
bigRect.length = bigRect.width;
Question 10. In C++, the ____ is an operator called the member access operator.
.
,
::
#
Question 11. A ____ sign in front of a member name on the UML diagram indicates that the member is a private member.
+
-
#
$
Question 12. Suppose you have the following UML class diagram of a class.
----------------------------------------------------------------------------------------------
clockType
-----------------------------------------------------------------------------------------------
-hours: int
-minutes: int
-seconds: int
-----------------------------------------------------------------------------------------------
-incrementHours{} : void
+equalTime{} : bool
+printTime{} : void
+clockType{}
+-clockType{}
+getTime{} : int
+setTime(in setHours : int, in setMinutes : int, in setSeconds : int) : bool
------------------------------------------------------------------------------------------------
According to the UML class diagram, which function is public and doesn't return anything?
incrementHours
equalTime
printTime
setTime
Question 13. Consider the following declaration.
class myClass
{
public:
void print();
private:
int x;
};
myClass myObject;
Which statement is legal?
myObject.print = 10;
myClass.print = 10;
myObject.print();
myClass.print();
Question 14. When composition is used, _____.
the host object is constructed first, and then the member objects are placed into it
member objects are constructed first, in the order they appear in the host constructor's initializer list
member objects are constructed first, in the order they are declared in their own class
member objects are constructed last, in the order they are declared in the host's class
Question 15. Composition and inheritance are two fundamental ways of relating _____.
classes
objects
class function members
class data members
Question 16. Aggregation is also sometimes called _____.
inheritance
instantiation
composition
encapsulation
Question 17. A(n) _____ relationship represents composition.
"has a"
"is a"
"part of"
logical
Question 18. If the derived class does not override a public member function of the base class, you may specify a call to that public member function that has parameters by _____.
using the name of the function and no parameter list
using only the name of the function
using the name of the function and the appropriate parameter list
Public member functions cannot be accessed in a derived class.
Question 19. The new classes that we create from the existing classes are called ____ classes.
sibling
base
derived
parent
Question 20. Which of the following statements does not correctly describe inheritance?
Going from a general description to a more specific description
Describes an "is a" relationship
Describes a "has a" relationship
Allows for reusable code
1. (TCO 1) Assume you have the following declaration.
int beta[50];
Which of the following is a valid element of beta? (Points : 4)
beta['0']
beta['1']
beta[0]
beta[50]
Explanation / Answer
1.beta[0]
2.only(i)
3.120
4.alpha={1 2 6 7 5}
5.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.