Final Exam COSC 1437 Review

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

destructor

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

friend

A(n) ____ function is a nonmember function that has access to all members of the class.

catch

A(n) ____________________ block specifies the type of exception it can catch and contains an exception handler.

conversion

A(n) ____________________ constructor converts its argument to an object of the constructor's class.

dynamic

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

operator

Any function that overloads an operator is called a(n) ____________________ function.

parameterized

Class templates are called ____ types.

studentPtr->gpa

Consider the following declaration of a struct: struct studentType { char name[26]; double gpa; int sID; char grade; }; studentType student; studentType *studentPtr; The statement (*studentPtr).gpa = 2.5; is equivalent to ___________________ = 2.5;.

member-wise initialization

Consider the following statement: ptrMemberVarType objectThree(objectOne); The values of the member variables of objectOne are being copied into the corresponding member variables of objectThree. This initialization is called the ____.

abstract

Consider the following statements: class shape { public: virtual void draw() = 0; virtual void move(double x, double y) = 0; . . . }; The code above is an example of a(n) ____________________ class definition.

reference

Consider the following statements: void pointerParameters(int* &p, double *q) { . . . } In the function pointerParameters, the parameter p is a(n) ____________________ parameter.

value

Consider the following statements: void pointerParameters(int* &p, double *q) { . . . } In the function pointerParameters, the parameter q is a(n) ____________________ parameter.

this

Every object of a class maintains a (hidden) pointer to itself, and the name of this pointer is ____.

int

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

eight

Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).

one

If you overload the binary arithmetic operator + as a member function, how many objects must be passed as parameters?

what

If you want to include members in your exception class, you typically include the function ____.

&

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

virtual

In C++, virtual functions are declared using the reserved word ____.

*

In C++, you declare a pointer variable by using the ____ symb

static

In ____ binding, the necessary code to call a specific function is generated by the compiler.

deep

In a ____ copy, two or more pointers have their own data.

shallow

In a ____ copy, two or more pointers of the same type point to the same memory.

True

Most operator functions can either be member functions or nonmember functions of a class.

dynamic

Run-time binding is also known as ____ binding.

template <class Type> function cType<Type>::func(parameters)

Suppose cType is a class template, and func is a member function of cType. The heading of the function definition of func is: ____.

cType<int> x;

Suppose cType is a class template, which can take int as a parameter. The statement: ____ declares x to be an object of type cType, and the type passed to the class cType is int.

Terminate the program.

Suppose you have written a program that inputs data from a file. If the input file does not exist when the program executes, then you should choose which option?

new

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

delete

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

copy

The ____ constructor is executed when an object is declared and initialized by using the value of another object.

address of

The ____ operator can be used to return the address of a private data member of a class.

virtual destructor

The ____________________ of a base class automatically makes the destructor of a derived class virtual.

data type

The ____________________ of the catch block parameter specifies the type of exception that the catch block can catch.

assignment

The ____________________ operator causes a member-wise copy of the member variables of the class.

executionrun

The binding of virtual functions occurs at program ____________________ time.

runtime_error

The class ____ is designed to deal with errors that can be detected only during program execution.

invalid_argument

The class ____ is designed to deal with illegal arguments used in a function call.

pointer

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

value

The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.

->

The function that overloads the ____ operator for a class must be declared as a member of the class.

const

The general form of the functions to overload the binary operators as member functions of a class is returnType operator#(____ className&) const;.

const className& operator=(const className&);

The general syntax for the function prototype to overload the assignment operator = for a class is ____.

friend stream& operator>>(istream&, className&);

The general syntax to overload the stream extraction operator >> for a class is ____.

stdexcept

The logic_error and runtime_error classes are defined in the header file ____.

operator<-

The name of the function to overload the operator <= is ____.

member selection

The only built-in operations on classes are assignment (=) and ____________________.

sizeof

The operators that cannot be overloaded are ., .*, ::, ?:, and ____________________.

bool

The return type of the function operator == is ____.

istream

The return type of the function to overload the operator >> must be a reference to a(n) ____ object.

int* p;

The statement int *p; is equivalent to int * p;, which is also equivalent to the statement ____________________.

*board[6]

The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;

catch

The try block is followed by one or more ____ blocks.

friend

To include the operator function operator+ as a nonmember function of the class rectangleType, its prototype in the definition of rectangleType is: ____ rectangleType operator+(const rectangleType&, const rectangleType&);

no

To overload the pre-increment (++) operator for a class, if the operator function is a member of that class, it must have ____ parameter(s).

#include <cassert>

To use the assert function in your program, you should include the statement ____.

classes

Using a class template, you can write a single code segment for a set of related ____.

12, 81

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

43, 43

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

33

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

46

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

this

When an object invokes a member function, the member function references the pointer ____ of the object.

two

When the post-increment operator is overloaded as a nonmember function of the class, the operator function has ____ parameter(s).

Increment

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

nullptr

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

overflow_error

Which of the following classes is derived from the class runtime_error?

bool operator!=(const rectangleType&) const;

Which of the following function prototypes overloads the != operator for the class rectangleType?

assignment

Which of the following is a built-in operation on classes?

className operator++(int);

Which of the following is the general syntax of the function prototype to overload the post-increment operator as a member function?

className operator++( );

Which of the following is the general syntax of the function prototype to overload the pre-increment operator ++ as a member function?

friend className operator++(className&);

Which of the following is the general syntax of the function prototype to overload the pre-increment operator as a nonmember function?

cType& operator[ ] (int index);

Which of the following is the syntax to declare the operator function operator[ ] as a member function of a class for nonconstant arrays?

const Type& operator[ ] (int index) const;

Which of the following is the syntax to declare the operator function operator[] as a member function of a class for constant arrays?

==

Which of the following operations is allowed on pointer variables?

Log the error and continue.

Which of the following options should you choose when an exception occurs in the program that analyzes an airline's ticketing transactions?

rulerType(const rulerType& myRuler)

Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType?

assignment

With the exception of the ____________________ operator and the member selection operator, operators must be overloaded to be used on class objects.

False

[T/F] A catch block specifies the type of exception it can catch and immediately terminates the program.

False

[T/F] A friend function does not have access to the private data members of the class.

True

[T/F] A memory leak is an unused memory space that cannot be allocated.

True

[T/F] A pointer variable is a variable whose content is a memory address.

True

[T/F] Both parameters of the function to overload the operator << are reference parameters.

False

[T/F] C++ provides all the exception classes you will ever need.

True

[T/F] Given the declaration int *p; The statement p = new int[50]; dynamically allocates an array of 50 components of type int and p contains the base address of the array.

True

[T/F] If p is a pointer variable, the statement p = p + 1; is valid in C++.

True

[T/F] In C++, >> is used as a stream extraction operator and as a right shift operator.

True

[T/F] In C++, operator is a reserved word.

False

[T/F] In C++, pointer variables are declared using the reserved word pointer.

False

[T/F] In C++, the dot operator has a lower precedence than the dereferencing operator.

False

[T/F] In C++, the member access operator arrow is >>.

False

[T/F] In the statement int* p, q; p and q are pointer variables.

True

[T/F] One of the typical ways of dealing with exceptions is to use an if statement.

False

[T/F] Operator functions typically return void.

True

[T/F] Operators can be overloaded either for objects of the user-defined types, or for a combination of objects of the user-defined type and objects of the built-in type.

True

[T/F] The associativity of the operator = is from right to left.

False

[T/F] The declaration of a friend function cannot be placed within the private part of the class.

True

[T/F] The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.

False

[T/F] The order of the catch blocks does not affect the program.

False

[T/F] Variables that are created during program execution are called static variables.

False

[T/F] When writing the definition of a friend function, the name of the class and the scope resolution operator precede the name of the friend function in the function heading.


Conjuntos de estudio relacionados

Java software solutions self review chapter 2

View Set

Algebra 1A- End of Semester Test: South Carolina Algebra IA

View Set

10.1 Practice 2 Parallel Lines & Transversals - Types of Angles

View Set

LIFE INSURANCE POLICY PROVISIONS, OPTIONS AND RIDERS

View Set

World civilization chapter 16 and 18 European expansion from book

View Set

Intermediate accounting- Chapter 12

View Set