Final question pool

¡Supera tus tareas y exámenes ahora con Quizwiz!

Consider the following statements: string str1 = "ABCDEFGHIJKLM";string str2; After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____".

BCDE

A class and its members can be described graphically using a notation known as the ____ notation. Group of answer choices

UML

Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with the component type int?

int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

Consider the following declaration: int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this statement?

int alpha[] = {3, 5, 7, 9, 11};

Inheritance is an example of a(n) ____ relationship.

is-a

Consider the following function prototype:int seqSearch(const listType& list, int searchItem);The actual parameter cannot be modified by ____.

list

Consider the statement int list[10][8];. Which of the following about list is true?

list has 10 rows and 8 columns.

To compare struct variables, you compare them ____.

member-wise

A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____.

n-dimensional array

The scope of a namespace member is local to the ____.

namespace

The C++ operator ____ is used to create dynamic variables.

new

Which of the following can be used to initialize a pointer variable?

nullptr

C++ provides ____ functions as a means to implement polymorphism in an inheritance hierarchy, which allows the run-time selection of appropriate member functions.

virtual

Given the declaration int *a;, the statement a = new int[50]; dynamically allocates an array of 50 components of the type ____.

int

A ____ sign in front of a member name on a UML diagram indicates that this member is a protected member.

#

A ____ sign in front of a member name on a UML diagram indicates that this member is a protected member. Group of answer choices

#

In C++, ____ is called the address of operator.

&

In C++, the null character is represented as ____.

'\0'

A ____ sign in front of a member name on a UML diagram indicates that this member is a public member.

+

In C++, the ____ is called the member access operator.

.

The syntax for accessing a struct member is structVariableName____.

.memberName

What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20};int j;for (j = 0; j < 5; j++)cout << list[j] << " ";cout << endl;

0 5 10 15 20

Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList?

0 through 99

What is the output of the following statements?int x = 33;int *q;q = &x;cout << *q << endl;

33

Considering the statement string str = "Gone with the wind";, the output of the statement cout << str.find("the") << endl; is ____.

10

What is the output of the following code?int *p;int x;x = 12;p = &x;cout << x << ", ";*p = 81;cout << *p << endl;

12, 81

The length of the string "Hello There. " is ____.

13

What is the output of the following program? #include <iostream>using namespace std;class bClass{public:void print() const;bClass(int a = 0, int b = 0);//Postcondition: x = a; y = b;private:int x;int y;};class dClass: public bClass{public:void print() const;dClass(int a = 0, int b = 0, int c = 0);//Postcondition: x = a; y = b; z = c;private:int z;};int main(){bClass bObject(2, 3);dClass dObject(3, 5, 8);bObject.print();cout << endl;dObject.print();cout << endl;return 0 ;}void bClass::print() const{cout << x << " " << y << endl;}bClass::bClass(int a, int b){x = a;y = b;}void dClass::print() const{bClass:print();cout << " " << z << endl;}dClass::dClass(int a, int b, int c): bClass(a, b){z = c;}

2 3 3 5 8

Consider the following statements:string str = "ABCDEFD";string::size_type position;After the statement position = str.find('D'); executes, the value of position is ____.

3

What is the output of the following code?int *p;int x;x = 76;p = &x;*p = 43;cout << x << ", " << *p << endl;

43, 43

What is the value of x after the following statements execute?int x = 25;int *p;p = &x;*p = 46;

46

Consider the following statement: double alpha[10][5];. The number of components of alpha is ____.

50

Suppose str = "ABCDEFGHI". The output of the statementcout << str.length() << endl;

9

Suppose str = "ABCDEFGHI". The output of the statementcout << str.length() << endl;is ____.

9

In C++, ____ is called the scope resolution operator.

::

Which of the following operations is allowed on pointer variables?

==

Which of the following is true about a derived class?

A derived class can redefine any public member function of the base class.

What does ADT stand for?

Abstract Data Type

Which of the following is true about classes and structs?

By default, all members of a struct are public and all members of a class are private.

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] << " ";cout << endl; Group of answer choices

Code results in index out-of-bounds

A struct variable can be passed as a parameter ____.

Either by reference or by value

Which of the following arithmetic operations is allowed on pointer variables?

Increment

Consider the following statements: struct supplierType {string name;int supplierID; };struct applianceType {supplierType supplier;string modelNo;double cost; }; applianceType applianceList[25];Which of the following best describes applianceList?

It is an array of structs

OOP implements ____.

OOD

Which of the following statements declares alpha to be an array of 25 components of the type int?

int alpha[25];

Which of the following is true about inheritance?

The public member variables of the base class become the public or private member variables of the derived class.

Which of the following statements about inheritance is true if memberAccessSpecifier is protected?

The public members of the base class become protected members of the derived class.

Suppose that str1, str2, and str3 are string variables. After the following statements execute, the value of str3 is "____".

abc-xyz

A member function of a class that only accesses the value(s) of the data member(s) is called a(n) ____ function.

accessor

A class object can be ____. That is, it is created each time the control reaches its declaration, and destroyed when the control exits the surrounding block.

automatic

Existing classes, from which you create new classes, are called ____ classes.

base

Typically, in a program, a struct is defined ____ in the program.

before the definitions of all the functions

Assume you have the following declaration int beta[50];. Which of the following is a valid element of beta?

beta [0]

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;}; Consider the accompanyingclassdefinition, and the declaration:rectangleType bigRect; Which of the following statements is correct?

bigRect.print();

Consider the following statements: struct rectangleData{double length;double width;double area;double perimeter;}; rectangleData bigRect;Which of the following statements is valid in C++?

cin >> bigRect.length;

Consider the following statements.struct circleData{double radius;double area;double circumference;}; circleData circle;Which of the following statements is valid in C++?

cin >> circle.radius;

Which of the following class definitions makes the public members of the class aClass become the public members of the class bClass?

class bClass: public aClass{ //...};

Which of the following is a valid definition of the derived class bClass?

class bClass: public aClass{//...};

Which of the following class definitions is correct in C++?

class studentType{public: void setData(string, double, int);private: string name;};

If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class, you use the statement ____.

classB::functionName();

____ is a "has-a" relationship.

composition

In C++, you can pass a variable by reference and still prevent the function from changing its value by using the keyword ____ in the formal parameter declaration.

const

clockType-hr: int-min: int-sec: int+setTime(int, int, int): void+getTime(int&, int&, int&) const: void+printTime() const: void+incrementSeconds(): int+incrementMinutes(): int+incrementHours(): int+equalTime(const clockType&) const: bool The word ____ at the end of several the member functions in the accompanying figureclassclockTypespecifies that these functions cannot modify the member variables of aclockTypeobject.

const

To guarantee that the member variables of a class are initialized, you use ____.

constructors

The C++ operator ____ is used to destroy dynamic variables.

delete

A class ____ automatically executes whenever a class object goes out of scope.

destructor

Consider the following declaration:char charArray[51];char discard;Assume that the input is:Hello There!How are you? What is the value of discard after the following statements execute?cin.get(charArray, 51);cin.get(discard);

discard = '\n'

An array created during the execution of a program is called a(n) ____ array.

dynamic

____ is the ability to combine data, and operations on that data, in a single unit.

encapsulation

Aggregate input/output operations are allowed on a struct variable.

false

As parameters to a function, class objects can be passed by reference only.

false

If inheritance is private, all members of the base class, including private members, become private members of the derived class.

false

In C++, the dot operator has a lower precedence than the dereferencing operator. Group of answer choices

false

In C++, the member access operator arrow is >>.

false

The public members of a class must be declared before the private members.

false

You can use arithmetic operators to perform arithmetic operations on class objects.

false

In row order form, the ____.

first row is stored first

Consider the following statements: struct supplierType {string name;int supplierID; };struct applianceType {supplierType supplier;string modelNo;double cost; }; applianceType applianceList[25];Which of the following statements correctly initializes the cost of each appliance to 0?

for (int j = 0; j < 25; j++)applianceList.cost[j] = 0;

Suppose that sales is an array of 50 components of type double. Which of the following correctly initializes the array sales?

for (int j = 0; j <= 49; j++) sales[j] = 0.0;

Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the elements of list?

for (int j = 0; j <= 9; j++) cout << list[j] << " ";cout << endl;

Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the following for loops sets the index of gamma out of bounds?

for (j = 0; j <= 50; j++) cout << gamma[j] << " ";

Given the following codenamespace globalType{void printResult();}

globalType::printResult();

If a function of a class is static, it is declared in the class definition using the keyword static in its ____.

heading

A struct is typically a ____ data structure.

heterogeneous

Consider the following statements: struct rectangleData{double length;double width;double area;double perimeter;}; rectangleData bigRect;rectangleData smallRect;Which of the following statements is legal in C++?

if (bigRect.length == smallRect.width)

Which of the following statements is used to simplify the accessing of all globalType namespace members?

ing namespace globalType;

The code int *p; declares p to be a(n) ____ variable.

pointer

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.

private

If a member of a class is ____, you cannot access it outside the class. Group of answer choices

private

The ____ members of an object form its external state.

public

To ____ a public member function of a base class in the derived class, the corresponding function in the derived class must have the same name, number, and types of parameters.

redefine

A class object can be ____. That is, it can be created once, when the control reaches its declaration, and destroyed when the program terminates.

static

The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the namespace ____.

std

Consider the following declaration: char str[15];. Which of the following statements stores "Blue Sky" into str?

strcpy(str, "Blue Sky");

The data type string has a named constant, ____, associated with it.

string::npos

Which of the following struct definitions is correct in C++?

struct studentType{ int ID;};

Consider the following statements:struct studentType1 {string name;int ID;double gpa; };studentType1 student1, student2;struct studentType2 {string name;int ID;double gpa; };studentType2 student3, student4;Which of the following statements is valid in C++?

student1.ID = student3.ID;

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];

Consider the following statements:struct supplierType {string name;int supplierID; };struct paintType {supplierType supplier;string color;string paintID; }; paintType paint;What is the data type of paint.supplier?

supplierType

The ____ function is used to interchange the contents of two string variables.

swap

You can assign the value of one struct variable to another struct variable of ____ type.

the same

A list has two items associated with it: ____.

the values and the length

A derived class can directly access the protected members of the base class.

true

A memory leak is an unused memory space that cannot be allocated.

true

Given the declarationint *p;The statementp = new int[50]; dynamically allocates an array of 50 components of type int and p contains the base address of the array.

true

In protected inheritance, public and protected members of the base class become the protected members of the derived class.

true

The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.

true

The one place where C++ allows aggregate operations on arrays is the input and output of C-strings.

true

When you pass an array as a parameter, the base address of the actual array is passed to the formal parameter.

true

class secretType{public:static int count;static int z;secretType();secretType(int a);void print();static void incrementY();private:int x;static int y;};secretType::secretType(){x = 1;}secretType::secretType(int a){x = a;}void secretType::print(){cout << "x = " << x << ", y = " << y<< "z = " << z<< ", count = " << count << endl;}static void secretType::incrementY(){y++;} Consider the accompanyingclassand member functions definitions. How many constructors are present in the class definition?

two

In C++, you can create aliases to a previously defined data type by using the ____ statement.

typedef

Which of the following is a valid C++ statement?

typedef int integer;

Consider the following class definitions:class bClass{public:void setX(int a);//Postcondition: x = a;void print() const;private:int x;};class dClass: public bClass{public:void setXY(int a, int b);//Postcondition: x = a; y = b;void print() const;private:int y;};Which of the following correctly sets the values of x and y?

void dClass::setXY(int a, int b){bClass::setX(a);y = b;}


Conjuntos de estudio relacionados

Chapter 12: Teams: Processes and Communication (Part 4: Group Mechanisms)

View Set

Top 10 Countries with Largest Populations

View Set

MGMT 3000 CH. 6, chp 6, MGT Module 8, MGT Ch 6 Smartbook

View Set

Chemistry 1030 - Intermolecular Forces

View Set