Programming Final Exam Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

True/False: There is no difference between defining an object of an ordinary class and an object of a template class

False

True/False: To decrement a number means to increase its value.

False

True/False: When a C++ expression is evaluated, binary operations are performed before unary operations.

False

True/False: When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private members.

False

True/False: When an operator has two operands of different data types, C++ always converts them both to double before performing the operation.

False

True/False: With pointer variables you can access, but you cannot modify, data in other variables.

False

True/False: You can overload the conditional operator to make it function as an unconditional operator

False

True/False: You can use pass by value when passing a C++ unique pointer to a function.

False

True/False: A class can have a member variable that is an instance of another class. This is called object nesting.

False

True/False: A class declaration creates an object.

False

True/False: A class must have exactly one constructor.

False

True/False: A constructor is a public class function that gets called whenever you want to re-initialize an object's member data.

False

True/False: A member function of a derived class may not have the same name as a member function of a base class

False

True/False: A program may not contain a "regular" version of a function and a template version of the function at the same time

False

True/False: A recursive function cannot call a function other than itself

False

True/False: A switch statement branches to a particular block of code depending on the value of a numeric (i.e. integer or floating-point) variable or constant.

False

True/False: A variable of the char data type can hold a set of characters like "January".

False

True/False: A while loop is somewhat limited, because the counter can only count up, not down.

False

True/False: A while loop may have a semicolon after the test expression and before the body of the loop, but it is not required.

False

True/False: ADT stands for Algorithmic Data Type.

False

True/False: Arrays can be passed to functions, but individual array elements cannot be.

False

True/False: At most one catch block may be attached to a single try block

False

True/False: Both function headers and function calls must list the data types of all data being passed to the function.

False

True/False: C++ permits you to overload the sizeof operator

False

True/False: If a C++ program contains the following array definition int score[10]; the following statement would store 100 in the first array element: score[1] = 100;

False

True/False: If employee is an array of objects with a public member function named setHourlyWage, the following statement correctly calls this method for employee[2]. employee.setHourlyWage[2](20.00);

False

True/False: If the sub-expression on the left side of an && operator is true, the expression on the right side will not be checked.

False

True/False: If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded also.

False

True/False: In C++ global and local numeric variables are initialized to zero by default.

False

True/False: In C++, if you overload the < operator, you must also overload the > operator.

False

True/False: In C++, the 5 basic arithmetic operators are addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^).

False

True/False: Memory cannot be allocated after a program is already running.

False

True/False: Relational operators connect two or more relational expressions into one, or reverse the logic of an expression.

False

True/False: The cin object lets the user enter a string that contains embedded blanks.

False

True/False: The following C++ test checks if the variable child is in the range 3 - 12. if (child >= 3 && <= 12)

False

True/False: The following pair of C++ statements will cause 3.5 to be output. double number = 7 / 2; cout << number;

False

True/False: The following statements will not print anything. x = 5; if(x < 5) cout << "Hello "; cout << "world \n";

False

True/False: The following two C++ statements perform the same operation. wages = reqPay + overTime; reqPay + overTime = wages

False

True/False: You may overload any C++ operator, and you may use the operator function to define non-standard operators, such as @ and ^.

False

Unit testing code coverage of at least 30% is considered very good.

False

When a loop is nested inside another loop, the outer loop goes through all its iterations for each iteration of the inner loop.

False

True/False: If the value of dollars is 5.0, the following statement will output 5.00 to the monitor: cout << fixed << showpoint << setprecision(4) << dollars << endl;

False (You would need setprecision(2))

True/False: The following statement sets the value of total to -3. total -= 3;

False, this is the subtract AND assignment operator

True/False: The following pair of C++ statements is legal const double taxRate; taxRate = .05;

False. (if it is a const you must initialize it on the same line)

What does the following statement do? typedef int oneDArray[20];

It makes oneDArray an alias for a data type that holds 20 integers.

A function object is an object that acts like a function and is also known as a functor

True

A mutable iterator gives you read/write access to the element to which the iterator points.

True

The STL contains templates for useful algorithms and data structures

True

To improve runtime performance C++11 introduced a new family of member functions that uses the emplacement technique to insert new elements

True

True/False: A base class cannot contain a pointer to one of its derived classes.

True

True/False: A class declaration provides a pattern for creating objects, but doesn't make any objects.

True

True/False: A constructor is a public class function that is automatically invoked (i.e., called) whenever a class object is created.

True

True/False: A pointer with the value 0 is called the NULL pointer

True

True/False: A private member function may only be called from a function that is a member of the same class.

True

True/False: A static member variable can be used when there are no objects of the class in existence

True

True/False: A structure has member variables, like an object, but they are usually all public and accessed directly with the dot operator, instead of by calling member functions.

True

True/False: A thrown exception for which there is no matching catch block will cause the execution of the program to abort

True

True/False: An Abstract data type (ADT) is a programmer-defined data type that specifies the values the type can hold, the operations that can be performed on them, and how the operations will be implemented.

True

True/False: An array name is a pointer constant because the address it represents cannot be changed during run-time.

True

True/False: An element of a two-dimensional array is referenced by the array name and two subscripts, first the element row number and then the element column number.

True

True/False: An initialization expression may be omitted from the for loop if no initialization is required.

True

True/False: Assuming moreData is a Boolean variable, the following two tests are logically equivalent. if (moreData == true) if (moreData)

True

True/False: By default, when an object is assigned to another, each member of one object is copied to its counterpart in the other object.

True

True/False: C++ is a case-sensitive language.

True

True/False: In C++ an expression that evaluates to 5, -5, or for that matter anything other than 0, is considered true by an if statement.

True

True/False: In C++ and other object-oriented programming languages, ADTs are normally implemented as classes.

True

True/False: Object-oriented programming is centered around objects that include both data and the functions that operate on them.

True

True/False: One reason for using functions is to break programs into a set of manageable units, or modules.

True

True/False: Pointers to a base class may be assigned the address of a derived class object.

True

True/False: Recursive algorithms tend to be less efficient than iterative algorithms

True

True/False: Relational expressions and logical expressions are both Boolean, which means they evaluate to true or false.

True

True/False: Some C++ operators cannot be overloaded by the programmer

True

True/False: Static binding occurs when the compiler binds a function call at compile time

True

True/False: The amount of memory used by an array depends solely on the number of elements the array can hold.

True

True/False: The base class access specification can be viewed as a filter that base class members must pass through when becoming inherited members of a derived class.

True

To retrieve a value from a map, you call the ________ member function and pass the ________ that is associated with the desired value.

at() key

In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its ________.

attributes, methods

Which is a better way to use unit tests?

automated testing

The _____ class constructor is called before the ______ class constructor

base, derived

A class may have ________ default constructor(s) and ________ destructor(s).

only one, only one

To overload the + operator you would write a function called

operator +

When an arithmetic expression contains two or more different operators, such as * and +, the order in which the operations is done is determined by

operator precedence

C++ allows you to overload

operators and functions

When converting some algebraic expressions to C++, you may need to insert ________ and ________ that do not appear in the algebraic expression.

operators, parentheses

An _______ operator can work with programmer-defined data types

overloaded

When you redefine the way a standard operator works when it is used with class objects you have _____ the operator

overloaded

If you do not furnish a(n) ________, an automatic memberwise copy will be performed when one object is assigned to another object.

overloaded assignment operator

If you want to make sure that member function of a class overrides another function in a base class you should declare the function with the keyword

override

In a function template, the programmer substitutes _______ for ________

parameters, data types

When a function needs access to an original argument passed to it, for example in order to change its value, the argument needs to be

passed into a reference parameter

the delete operator should only be used on pointers that

point to storage allocated by the new operator

In C++, a value, can be raised to a power by using.

pow function

#include <iostream>is an example of a(n)

preprocessor directive

The while loop is a(n) ________ loop, whereas the do-while loop is a(n) ________ loop.

pretest, post test

______ members of a base class are never accessible to a derived class

private

The ________ is used to protect important data.

private access specifier

Protected members of a base class are like _______ with the exception that they may be accessed by derived classes

private members

A function ________ eliminates the need to place the function definition before all calls to the function.

prototype

A(n) ________ member function may be called by a statement in a function that is outside of the class.

public

An object typically hides its data, but allows outside code to access it through its

public member functions

How do you add an element to a vector?

push_back()

The _____ algorithm uses recursion to sort an array

quicksort

The following statement for(int val : myArray) cout << val << " "; is an example of a(n)

range-based for loop

A _____ function is one that calls itself

recursive

The expression x < y is called a(n) ________ expression.

relational

The while loop has two important parts: a condition that is tested and a statement or block of statements that is

repeated as long as the condition is true

The vector class has a ________ member function which can be used to request an increase in the vector's capacity and a ________ member function to decrease a vector's capacity.

reserve(), shrink_to_fit()

What method do you use to increase the size of of a vector? Give the name only.

resize

A void function is one that

returns no value

Operator associativity is either left to right or

right to left

Two types of container classes in the STL are

sequence and associative

the _______ stream manipulator can be used to establish a field width for the value immediately following it

setw

A C++ character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks.

single,double

A reason to overload the ________ is to write classes that have array-like behavior.

square brackets []

A member function that is declared ______ cannot use the this pointer

static

A(n) ________ member variable may be accessed before any objects of the class have been declared.

static

If a member variable is declared ____ all objects of that class share access to that variable

static

Which of the following expressions will evaluate to 2.5: A) static_cast(5) / 2 B) 5 / static_cast(2) C) static_cast<double>(5/2) D) All of the above E) Both A and B, but not C

static_cast(5) / 2 5 / static_cast(2) but not static_cast<double>(5/2)

A ________ is a dummy function that is called instead of the actual function it represents, to test that the call to and return from the function are working correctly.

stub

By using the same ________ you can build relationships between data stored in two or more arrays.

subscript

To access an array element, use the array name and the element's

subscript

The beginning of a function template is marked by a

template prefix

An overloaded function is one

that has the same name as another function

a pointer may be initialized with

the address of an existing object of the appropriate type

When the less than ( < ) operator is used between two pointer variables, the expression is testing whether

the address of the first variable comes before the address of the second variable in the computer's memory.

When the final value of an expression is assigned to a variable, it will be converted to

the data type of the variable

The set of operations supported by the unique_ptr class include

the dereferencing operators * and ->.

Suppose that a function dynamically allocates a block of memory with a local pointer variable p pointing to the allocated block. Suppose further that there are no other pointers referencing that block of memory, and the function returns without doing a delete on p. Then

the program will suffer from memory leaks

When a member function is defined outside of the class declaration, the function name must be qualified with the class name, followed by

the scope resolution operator (::).

When an array is passed to a function, it is actually ________ the array that is passed.

the starting memory address of

To dereference a structure pointer and simultaneously access a member of the structure, the appropriate operator to use is

the structure pointer operator, ->

When you work with a dereferenced pointer, you are actually working with

the variable whose address is stored in the pointer variable

The ______ is a special built-in pointer that is available to a class's instance member functions

this pointer

To use the binary_search() algorithm you need to include ________

three arguments which are two iterators and a value

When an error occurs an exception is

thrown

The name of a destructor must begin with

tilde (~)

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement.

trailing else

The library function move() can be used to

transfer ownership of a managed object from one unique_ptr object to another.

A set is an associative container containing elements that must all be unique.

true

In order to insert an element in the middle of a C++ array, you would need to copy (or move) elements after the point of insertion.

true

True/False: A constructor that takes a single parameter of a type other than its class is called a convert constructor

true

True/False: A derived class may become a base class if another is derived from it

true

True/False: A static member function can be called independently of any object of the class

true

True/False: Although global variables can be useful, it is considered good programming practice to restrict your use of them.

true

True/False: It is legal to subtract a pointer variable from another pointer variable

true

True/False: It is possible to declare an entire class as a friend of another class

true

True/False: The structure member selector operator . cannot be overloaded

true

True/False: When a recursive function directly calls itself, this is known as direct recursion

true

True/False: When you overload an operator you cannot change the number of operands taken by the operator

true

True/False: if an rvalue reference refers to a memory location, that memory location becomes an lvalue

true

What will the following expression evaluate to? !( 6 > 7 || 3 == 4)

true

The statement shared_ptr<int> p(new int); involves

two allocations of two different dynamic blocks of memory.

The quicksort algorithm works on the basis of

two sublists and a pivot

A(n) ______ is used in a function template to specify a generic data type

type parameter

A for statement contains three expressions: initialization, test, and

update

Unlike regular variables, arrays can hold multiple

values

You may define a(n) ________ in the initialization expression of a for loop.

variable

A container sequence container that is dynamic in size is a(n)

vector

A virtual function is declared by placing the keyword _____ in front of the return type in the base class's function declaration

virtual

In C++, polymorphism is based on the ability to make member functions of a class

virtual

_________ functions are dynamically bound by the compiler

virtual

For data validation, it is best to use a(n)

while loop

A static local variable is one

whose value is retained between function calls

to indicate that a member function of a class is pure vital

you must put = 0 where the body of the function would go

A function can have ________ parameters, and it can have either zero or one return value(s).

zero to many

The ________ operator is known as the logical OR operator.

||

True/False: The only difference between C-strings and string objects is how they are declared and internally stored. They are used the exact same way.

False

True/False: The range-based for loop may be used with arrays, but not with vectors.

False

True/False: The scope of a variable is the program it is defined in.

False

It is best to cover as many functions as you can in each unit test.

False

What is the name of the C++ head file that helps with unit testing?

assert.h

The ________ directive causes the contents of another file to be inserted into a program.

#include

To use the map class, you must include

#include <map>

If arr is an array identifier and k is an integer, the expression arr[k] is equivalent to

*(arr + k)

________ are C++ operators that change their operands by one.

++ and --

to dereference an object pointer and access one of the object's members, use the

-> operator

Object composition is useful for creating a ______ relationship between classes

has-a

The cin object must be followed by

one or more stream extraction (>>) operators.

What will the following code segment display? enum Season {Spring, Summer, Fall, Winter} favoriteSeason; favoriteSeason = Summer; cout << favoriteSeason;

1

The expression 5 % 2 evaluates to

1 (modulus division)

What will the value of argc be if you run the following command? ./a.out hello 1234 56 34.33 false a b c d

10

The expression 5 / 2 evaluates to

2 (int division)

int x[20]; what is the value of this expression: sizeof(x) / sizeof(*x)

20

What value will be assigned to the variable number by the following statement? int number = 7.8;

7

What does the following C++ expression evaluate to? 6 - 6 / 3 + 3

7 (operator preference)

What will the following code print? num = 8; cout << --num << " "; cout << num++ << " "; cout << num;

7 7 8

To use a vector instead of an array in C++ the name of the library you #include is ____________.

<vector>

The ________ operator may be used to assign one object to another.

=

The ________ operator is used in C++ to test for equality.

==

the ___ operator always follows the cin object, and the ____ operator follows the cout object

>>, <<

In the statement template <class T> what does T represent

A generic data type that is used in a function template

Which of the following will allow an entire line of text to be read into a string object, even if it contains embedded blanks? A) getline() B) cin >> C) cin.get() D) cin.ignore() E) both A and B, but not C or D.

A) getline()

Polymorphism in C++ will not work unless

A) pointers or references are being used

Which arithmetic operations can be performed on pointers?

Addition , subtraction , preincrement, and postincrement

Which of the following definitions will allow the variable total to hold floating-point values? A) float total; B) double total; C) auto total = 0.0;

All of these.

What will the following statement do if x equals 17 and answer = 20? answer = x > 100 ? 0 : 1;

assign 1 to answer

The statements in the body of a do-while loop are executed

at least once

Which of the following statements correctly deletes a dynamically-allocated array pointed to by p?

delete [] p;

If number is an int variable, both of the following statements will print out its value: cout << number; cout << "number";

False

In the statement class Car:protected Vehicle, what is being protected?

Base class members

Recursion can be used to

Both compute factorials and find the greatest common divisor of two integers (GCD), but not program things that cannot be programmed without recursion

In the statement class Car:protected Vehicle, which is the derived class?

Car

If Circle is the name of a class, which of the following statements would create a Circle object named myCircle?

Circle myCircle;

Each function/method only needs 1 unit test.

False

Which of the following statements about ADTs are true? A) They do They specify the values the data type can hold B) They specify the operations the data type can perform C) They hide the details of how the data type is implemented. D) A and B but not C

D

________ are data items whose values cannot change while the program is running. A) none of these B) Integers C) Variables D) Literals E) Fixed data

D) Literals

When an object or structure variable is passed to a function as a constant reference A. the function accesses the original object, rather than a copy of it. B. the function cannot make any changes to the member variables. C. it is more efficient than passing it by value. D. all of the above are true. E. A and B are true, but not C.

D. all of these are true

Which of the following statements doubles the value stored in answer? A) answer += 2; B) answer *= 2; C) answer = answer * 2; D) All three of the above E) Both B and C, but not A

E) Both B and C, but not A

Which of the following is/are valid C++ identifiers? A) Both June_2010 and 2010June. B) June-2010 C) June.2010 D) 2010June E) June_2010

E) June_2010

C++ is one of the few languages that has support for unit testing.

False

Which of the following statements is not true

The value element in a map is used to locate the key

________ can be used as pointers.

array names

A structure variable is similar to a class object in which of the following ways? A) Its data can be initialized with a constructor B) It can be passed to a function or returned from a function C) It has member data that is usually private and accessed through public member functions. D) Its data can be initialized with a constructor and It can be passed to a function or returned from a function, but not It has member data that is usually private and accessed through public member functions.

Its data can be initialized with a constructor and It can be passed to a function or returned from a function, but not It has member data that is usually private and accessed through public member functions.

C++ automatically places ________ at the end of a string literal.

NULL terminator

Which of the following statements correctly creates an enumerated data type and defines an object of that type? ENUM Season {Spring, Summer, Fall, Winter} favoriteSeason; enum Season = {"Spring", "Summer", "Fall", "Winter"} favoriteSeason; enum Season {Spring, Summer, Fall, Winter}, enum favoriteSeason; enum Season = {Spring, Summer, Fall, Winter}, Season favoriteSeason;

None of these

If s1 and s2 are string objects, s1 == s2 is true when

None of these because in each case one or more characters in the strings have different ASCII codes

___________ can be used to override the rules of operator precedence

Parentheses

If Square is the name of a class, which of the following statements would create a Square object named box?

Square box;

Which of the following statements about named constants is/are true? A) A named constant must be initialized with a value at the time it is declared B) The initial value of a named constant, cannot be changed during the program execution are true C) The identifier name of a named constant can only contain capital letters and underscores is not. D) All are true E) A named constant must be initialized with a value at the time it is declared AND The initial value of a named constant, cannot be changed during the program execution are true BUT NOT The identifier name of a named constant can only contain capital letters and underscores is not.

TRUE: A) A named constant must be initialized with a value at the time it is declared B) The initial value of a named constant, cannot be changed during the program execution are true NOT TRUE: C) The identifier name of a named constant can only contain capital letters and underscores is not.

The following 4 lines of C++ code, use strings. string firstName; char lastName[7]; firstName = "Abraham"; lastName = "Lincoln"; Which of the following statements is/are true?

The string object is assigned a value correctly, but the C-string is not.

True/False: The block of code in the body of a while statement can contain an unlimited number of statements, provided they are enclosed in a set of braces.

True

True/False: The cin object can be used to input more than one value in a single statement.

True

True/False: The expression s->m has the same meaning as (*s).m

True

True/False: The expression s->m is meaningful only when s is a pointer to a structure and m is a member of the structure

True

True/False: The following statement sets sum1, sum2, and sum3 all to zero. sum1 = sum2 = sum3 = 0;

True

True/False: The following two expressions evaluate to the same thing: c + a * b c + (a * b)

True

True/False: The following two statements will assign the same value to result result = a + b * c; result = b * c + a;

True

True/False: The this pointer is a special built-in pointer that is automatically passed as a hidden argument to all instance member functions.

True

True/False: When a class contains a pointer to dynamically allocated memory, it a good idea to have the class overload the assignment operator.

True

True/False: When an operator's operands are of different data types, such as int and double, C++ automatically converts one of them so that they are the same data type.

True

True/False: When arguments must be passed to the base class constructor, they are passed from the derived class constructor's header line.

True

True/False: When you create a vector it is unnecessary to specify how many elements it will hold because it will expand in size as you add new values to it.

True

True/False: When you pass an array as an argument to a function, the function can modify the contents of the array.

True

True/false: The C++ mechanism for exception handling encloses code that might throw an exception in a try block and puts exception handling code in catch blocks attached to the try block

True

When you declare an iterator to work with a container, the compiler automatically chooses the right type

True

in the statement class Car::public Vehicle, which is the base class?

Vehicle

In a C++ program, two slash marks ( // ) indicate the beginning of

a comment

When overloading the operator ++, ________ is used to distinguish preincrement from postincrement.

a dummy integer parameter

To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use ________ loop.

a for loop

An lvalue is

a memory location that is associated with a name that can be used by different parts of the program to access the memory location.

A C++ member function that sets or changes the value stored in a member variable is called

a mutator

Hand tracing a program is

a program debugging technique.

Memory leaks occur in a program when

a programmer fails to use delete on a pointer whose memory was allocated by the new operator.

C++ requires that a copy constructors parameters be

a reference to an object

A two-dimensional array can be viewed as

a table with rows and columns

An rvalue is

a temporary value that cannot be accessed from a different part of the program.

Which of the following defines an array object that holds three strings

array<string, 4> items = ("blue", "green", "yellow")

The base class's ________ affects the way its members are inherited by the derived class.

access specification

A variable that keeps a running total of data values is called a(n)

accumulator

The term pointer can be used interchangeably with

address

Assuming that arr is an array identifier, the statement sum += *arr;

adds the value stored in arr[0] to sum

A situation in which every object of a class A has a pointer to an object of a class B and the objects of the class B may outlive objects of class A is called

aggregation

Which of the following statements correctly initialize the value variable?

all of these

You may use the type pointer to a structure as the type of a a. function parameter b. structure member c. function return type d. All of these e. None of these

all of these

Which of the following statements is not valid C++ code

all of these are invalid

The ________, also known as the address operator, returns the memory address of a variable.

ampersand(&)

A class with at least one pure vital function is called

an abstract class

A C++ member function that uses, but does not change, the value of a member variable is called

an accessor

In the following statement, what is 22.0? cout << sqrt(22.0);

an argument

The elements of an array can be

any of these

A(n) ________ is information that is passed to a function, and a(n) ________ is a special variable that receives and holds that information.

argument, parameter

A good reason for overloading an operator is to enable it to

be used with types defined by the programmer

A flag is a variable, usually of data type ________, that signals whether or not some condition exists.

bool

in an inheritance situation the new class that you create from an existing class is known as the

both derived class and child class

If setSide is a Square class function and box is a Square object, which of the following statements would set the length of box's side to 5?

box.setSide(5);

The bad_alloc exception is thrown

by the new operator

When only a copy of an argument is passed to a function, it is said to be passed

by value

the _____ of recursion is the number of times a recursive function calls itself

depth

A function ________ is a statement that causes a function to execute.

call

When you derive a class from an existing class, you

can add both new data and new functions

a recursive function that does not correctly handle its base case may

cause an infinite chain of recursive calls

The ________ object causes data to be input from the keyboard.

cin

______ causes a program to wait until information is typed at the keyboard and the Enter key is pressed

cin object

A constructor must have the same name as the

class

In the statement template <class T> what does the word class indicate

class is a keyword that indicates that T is a type parameter

To use the sqrt() function, or other mathematical library functions, you must #include the ________ header file in your program.

cmath

It is a good idea to make a copy constructor's parameters ________ by specifying the ________ keyword in the parameter list.

constant, const

A(n) ______ is a class that stores data and organizes it in some fashion

container

The most important data structures in the STL are

containers, iterators

A(n) ______ is a special function that is called whenever a new object is created and initialized with data from another object of the same class

copy constructor

Whena. class contains a pointer to dynamically allocated memory it is a good idea to equip the class with a

copy constructor

If you do not furnish a(n) for a class, a default will be provided for you by the compiler

copy constructor, assignment operator, constructor

Which of the following will cause the next output to begin on a new line?

cout << endl;

The ________ is used to display information on the computer's screen.

cout object

The ________ class destructor is called before the ________ class destructor.

derived, base

A constructor that does not require that any arguments be passed to it is called a(n) ________ constructor.

default

A(n) ________ argument is one that is automatically passed to a parameter when the argument is left out of the function call.

default

the statement double *num;

defines a pointer variable called num

You must have a(n) ________ for every variable you include in a program.

definition

If you allocate space for an array like the previous question, then you must deallocate it using: ________[ ] values;

delete

To use an output file in a C++ program you must

do create a file stream object that will "point to" (i.e. reference) the file AND open the file, BUT not make sure the file already exists.

The statement cout << setw(4) << num4 << " ";

does none of these (it shifts three blank space, 4 including the first digit)

Public members of a class object can be accessed from outside the class by using the

dot operator

Class templates allows you to create one general version of a class without having to

duplicate code to handle multiple data types

Select all that apply. Which of the following are member functions of the vector class that use emplacement

emplace(), emplace_back()

A technique introduced by C++11 to improve runtime performance is known as

emplacement

The bundling of an object's data and functions together is called

encapsulation

What is the name of the method that tells you if you have reached the end of the file you are reading?

eof

Which method would you use to remove an element from a C++ vector? Give ONLY the name of the method, nothing else.

erase

_____ are used to signal errors or unexpected events that occur while a program is running

exceptions

Program code that can be evaluated to a value is called a(n)

expression

An associative container stores data in a non-sequential way so it is slower to locate elements than a sequential container

false

In order to insert an element in the middle of a C++ vector, you would need to copy (or move) elements after the point of insertion.

false

The concept of arrays is unique to C and C++.

false

True/False: A C++ unique pointer (unique_ptr) can be initialized with the value of another unique pointer.

false

True/False: A derived class may not have any classes derived from it

false

True/False: A static member function cannot be called if no objects of the class exist

false

True/False: If a function f is a friend of a class A, and the class A is a friend of a class B, then the function f is able to access private members of B.

false

True/False: If a function has no return statement, the flow of control moves to the next function in the file when the closing brace of the function body is reached.

false

True/False: If an exception is not caught, it is stored for later use

false

True/False: In an inheritance situation you cant pass arguments to a base class constructor

false

True/False: Indirect recursion means that a function calls itself several times

false

True/False: The this pointer is automatically passed to static member functions of a class

false

True/False: When you make a function call, the order of the arguments you send does not matter as long as the number of arguments matches the number of parameters the function has.

false

True/False: You may use the exit() function to return the flow of control from a function back to main() regardless of where the function was called from.

false

True/False: The following C++ statement will assign 1.5 to the result variable. int result - 3.0 / 2.0;

false (you need to cast it as a double)

A ____ function is not a member of a class, but it has access to the private members of the class

friend

To use files in a C++ program you must include the ________ header file.

fstream

What is the name of the C++ library you need to include in order to perform file I/O in your program?

fstream

Select all that apply. An object of a class that overloads the function call operator is a(n)

functor, function object

Accessors are sometimes called ________ functions and mutators are sometimes called ________ functions.

get, set

A ________ variable is declared outside all functions.

global

The bool data type

has only two values: true and false

The ________ statement executes one statement, or block of statements, if a condition is true and skips it, doing nothing, if the condition is false

if

The ________ statement acts like a chain of if statements. Each performs its test, one after the other, until one of them is found to be true or until the construct is exited without any test ever evaluating to true.

if/else if

The statement int grades[ ] = { 100, 90, 99, 80 };is an example of

implicit array sizing

With pointer variables, you can ________ manipulate data stored in other variables.

indirectly

_______ allows us to create new classes based on existing classes

inheritance

________ is commonly used to extend a class, or to give it additional capabilities.

inheritance

In a for statement, the ________ expression is executed only once.

initialization

When the body of a member function is defined inside a class declaration, it is called a(n) ________ function.

inline

When a program lets the user know that an invalid menu choice has been made, this is an example of

input validation

An object is a(n) ________ of a class.

instance

An object is an _______ of a class

instance

Each object of a class has its own copy of the class's

instance member variables

When three different objects of a class are created, they are said to be separate ________ of the class.

instances

Provide the word needed to complete this C++ declaration which creates a vector of integers. vector <______> values;

int

What is the data type of the first parameter on the main program? HINT: we call it argc

int

The code segment int *ptr; has the same meaning as

int* ptr;

To use stream manipulators, you should include the _______ header file

iomanip

In any program that uses the cin object, you must use the #include

iostream header file

The ++ operator

is a unary operator. can operate in prefix or postfix mode. adds one to the value of its operand. ALL OF THESE!!!!

A destructor is a member function that

is automatically called when an object is destroyed.

A function may return a pointer, but the programmer must ensure that the pointer

is pointing to an object that is still valid after the return of the function

A c++ smart pointer

is used to ensure that memory that is no longer in use is automatically deleted.

This code loops through the elements of a vector. Provide the missing word. for (vector<int>::_____________ it = values.begin(); it != values.end(); it++)

iterator

A sentinel is a special value that

marks the end of a list of values

Polymorphism is when ________ in a class hierarchy perform differently, depending upon which object performs the call.

member functions

A pure vital function

must be overridden in a derivedclass for the function to be useful

If setRadius is a Circle class function and myCircle is a Circle object, which of the following statements would set myCircle's radius to 2.5?

myCircle.setRadius(2.5);

What is always the 1st command line argument to a C++ program?

name of the program

One way to dynamically allocate space for an array is like this: int *values = ______ int[100];

new

A constructor may have a return type of

none of these

Arguments are passed to the base class destructor function by the ____ class _____ function

none of these

Which of the following statements will correctly carry out the operation stated in the comment to its right?

none of these

The following statement number = rand() % 5 + 10; assigns number a value in the range of

none of these (correct answer is 10-15 (15 being exclusive))

What does the last line in this code do? vector<int> values; values.push_back(40); values.push_back(20); values.push_back(50); values[5] = 10;

nothing

Beginning with C++ 11, the recommended value for a pointer whose value is invalid is

nullptr

Which of the following statements will assign number a value from 90-100 A) number = rand() % 90 + 10; B) number = rand() % 90 + 11; C) number = rand() % 10 + 90; D) number = rand() % 11 + 90; E) None of these

number = rand() % 11 + 90;

The process of having a class contain an instance of another class is known as

object composition


संबंधित स्टडी सेट्स

Microcontrollers for everyone Quiz 1

View Set

World History Terms: Unit 3 - Chapter 9

View Set

NMNC 1110 EAQ 9: Health Disparities

View Set

The Reformation Unit - MCQ and Terms

View Set

Prep U - Qs / Chapter 47: Lipid-Lowering Agents

View Set

Final for ADS 105 Chapter 9 & 10

View Set

PED 116 FINAL EXAM (CHAPTER 10 )

View Set