Expert Answers

Consider the following statement:
intalpha[25][10];
Which of the following statements about alpha is true?
Rows of alpha are numbered 0…24 and columns are numbered 0…9.
Rows of alpha are numbered 0…24 and columns are numbered 1…10.
Rows of alpha are numbered 1…24 and columns are numbered 0…9.
Rows of alpha are numbered 1…25 and columns are numbered 1…10.

Consider the following statements.
int alpha[10][5] = {0};
intj,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;
Only (i)
Only (ii)
Both (i) and (ii)
None of these

Given the following declaration:
int j;
int sum;
double sale[10][7];
which of the following correctly finds the sum of the elements of the fourth column of sale?
sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[j][3];
sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[j][4];
sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][4];
sum = 0;
for(j = 0; j sum = sum + sale[j][3];

The member variables of a class
must be of the same data type.
must be in the same section–either public or private.
can be any data type.
must be initialized in the class definition.

The member functions of a class should usually be
private.
protected.
templates.

In C++, which terms mean the same thing?
Member functions and objects
Member variables and properties
Objects and classes
Member variables and objects

Suppose that you have the following UML class diagram of a class.

Which of the following is the name of the class?
clock
clockType
Type
ClockType

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?
incrementHours
equalTime
printTime
setTime

A class and its members can be described graphically using a notation known as the _____ notation.
OON
OOD
UML
OOP

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?
rectangle rectangleType;
class rectangleType rectangle;
rectangleType rectangle;
rectangle rectangleType.area;

Which is a correct preprocessor directive statement?
define PI = 3.141593
define PI = 3.141593;
#define PI 3.141593
#define PI = 3.141593

When creating a macro, which preprocessor directive is used?
ifndef
define
ifdef
endif

Assuming that a multifile, object-oriented C++ project has both class definition and class implementation files, what type of function statement is actually placed in the class definition file?
Function call statement
Function prototype
Function implementation
Function argument list

All preprocessor directives begin with a(n) _____.
underscore
blank space
#
&

Which one of the commonly used include (header) files is not covered by the std namespace?
math
iomanip
string
iostream

Which statement correctly describes the default access attributes of both classes and structures?
Structures are private by default and classes are private by default.
Structures are public by default and classes are public by default.
Structures are public by default and classes are private by default.
Structures have no default access attribute and classes are private by default.

Which of the following statements is an accurate example of composition?
A car has an engine.
A car is an automobile.
A car is an object.
A car has a class.

Single inheritance means
that the derived class is derived from a single base class.
that only multiple classes can be derived from the given base class.
that only one base class can be derived.
single inheritance is not possible in C++.

The constructor of a derived class
cannot specify a call to the constructor of a base class in the body of the constructor function definition.
can specify a call to the constructor of a base class but only when the access specifier for the class set is protected.
can specify a call to the constructor of a base class in the body of the function definition.
can specify a call to the constructor of a base class in the body of the constructor function definition.

Which of the following is not true about public inheritance?
All public member functions of the base class become the public member functions of the derived class.
All public member variables of the base class become the public member variables of the derived class.
All public members of the base class become the public members of the derived class.
The public member variables of the base class become the private member variables of the derived class.

Which of the following statements about inheritance is true if the memberAccessSpecifier is protected?
The private members of the base class become protected members of the derived class.
The derived class can directly access any member of the base class.
The public members of the base class become protected members of the derived class.
The protected members of the base class become private members of the derived class.

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?
BClass constructor first, AClass constructor second
AClass constructor first, BClass constructor second
BClass constructor only; the AClass constructor is not called if AClass derived private from BClass
AClass constructor only; the BClass constructor is not called if BClass derived private from AClass

Which of the following base class members is never inherited by a derived class, regardless of access attributes?
Mutator
Accessor
Constructor
Data

Which of the following base class members is never inherited by a derived class, regardless of access attributes?
Mutator
Data
Accessor
Destructor

Which is the general syntax of the namespace definition statement?
namespace namespace_name { members }
using namespace namespace_name
using namespace namespace_name;
namespace std { members }