Final Exam

That a pure virtual function cannot have an implementation

The main difference between a pure virtual function and a virtual function is:

A colon as in bitfield : 4

The number of bits in a bit field is specified with:

inputStream.tie(0).

Untying an input stream, inputStream, from an output stream, outputStream, is done with the function call:

Member objects are constructed first, in the order they are declared in the host's class

When composition (one object having another object as a member) is used

A class is an instance of its object.

Which statement is false?

It must be overloaded twice; the operator+ function that takes the object as the left operand must be a member function, and the other operator+ function must be a global function

An overloaded + operator takes a class object and a double as operands. For it to be commutative (i.e., a + b and b + a both work):

fstream

Select the proper object type.
__________ file("file.dat", ios::in | ios::out);

You must explicitly delete the memory that's managed by a unique_ptr before the object goes out of scope.

[C++11]: Which of the following statements about a unique_ptr object is false?

A nonconstant pointer to nonconstant data.

A function that modifies an array by using pointer arithmetic such as ++ptr to process every value of the array should have a parameter that is:

a or b

[C++11]: To prevent class objects from being copied or assigned, you can:

all of the above

Which of the following is a compilation error?

static

Which of the following is not a kind of inheritance in C++

sum = sum - 30 should be sum = sum + 30 or else the loop may never end.

What is wrong with the following while loop?
while (sum <= 1000) {
sum = sum - 30;
}

Can result in changes to the value of an unrelated variable.

Referencing elements outside the array bounds with the [] operator:

The rightmost bit of x is set to 0

Let x be an unsigned int on a machine with 4-byte unsigned ints. What effect does
x>>=1;
x<<=1;
have?

ints

The functions of the character-handling library typically manipulate characters as:

global

Functions that are not members of a class are called ________ functions

std::cin

The ________ object enables a program to read data from the user

cout.fill(' ');

Which of the following statements restores the default fill character?

int, char

Converting from type ________ to type ________ will result in the loss of data

Any transition arrow can be reversed

Which of the following is not one the rules for forming structured programs

Declaring an object to be const

Which of the following statements will not produce a syntax error?

strncmp(string1, string2, 5);

Assuming that string1 = "hello" and string2 = "hello world", which of the following returns 0?

Can reduce a function's execution time but increase program size

The inline keyword

int or unsigned

A bit field must be declared as a:

Declares a function called mySqrt which takes an integer as an argument and returns a double

The function prototype
double mySqrt(int x);

1.23457
1.235
1.235

What will be output by the following statements?
double x{1.23456789};
cout << fixed;
cout << setprecision(5) << x << endl;
cout.precision(3);
cout << x << endl;
cout << x << endl;

Final state

In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

cout << static_cast<void*>(string);

Which of the following prints the address of character string string given the following declaration?
char* string{"test"};

A nonconstant pointer to constant data

A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is

An object data member is not initialized in the member initialization list and does not have a default constructor.

An error occurs if

The name of the function

Which of the following is not included in a function's activation record?

All classes that directly inherit from this class will override this method

The line:
virtual double earnings() const = 0;
appears in a class definition. You cannot deduce that:

The President

If Americans are objects of the same class, which of the following attributes would most likely be represented by a static variable of that class?

Enclose its own catch blocks

The try block cannot:

Two-byte unsigned int

A variable that can have values only in the range 0 to 65535 is a:

Are defined, but the programmer never intends to instantiate any objects from them.

Abstract classes:

sort(begin(values), end(values));

[C++11]: Given a built-in array of ints named values, which of the following statements would sort the array?

*this.x

Inside a function definition for a member function of an object with data member x, which of the following is not equivalent to this->x:

\

Which of the following is the escape character?

Nesting

Having a loop within a loop is known as:

Date Date::operator++(int)
{
Date temp{*this};
Increment();
return temp;
}

There exists a data type Date with member function Increment that increments the current Date object by one. The ++ operator is being overloaded to postincrement an object of type Date. Select the correct implementation:

The class does not define any constructors

The compiler will implicitly create a default constructor if:

In the new standard, you should use the constant null_ptr to initialize a pointer instead of 0 or NULL

[C++11]: Which of the following statements about pointer initialization and values is false?

Extra blank lines

Which of the following does not cause a syntax error to be reported by the C++ compiler?

Require the scope resolution operator only when being defined outside of the definition of their class.

Member function definitions:

The object code with the libraries

The linker links

ln.

Which of the following is not included in <cmath>?

Until explicitly set to a different setting.

Parameterized stream manipulator setfill specifies the fill character that's displayed when an output is displayed in a field wider than the number of characters or digits in the output. The effect of setfill applies:

All of the above

Which of the following does counter-controlled iteration require?

internal

Which of the following stream manipulators causes an outputted number's sign to be left justified, its magnitude to be right justified and the center space to be filled with fill characters?

It maximizes execution performance

All of the following are reasons to use recursion except:

11.00

What will be output by the following statement?
cout << showpoint << setprecision(4) << 11.0 << endl;

Two forward slashes (//)

End-of-line comments that should be ignored by the compiler are denoted using:

The definition of a function usually is visible to other functions.

All of the following are true of functions except:

Command-line arguments.

A string array is commonly used for:

Release candidate

Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the community?

Changes the value of the object to which its operand points.

Select the false statement. The reinterpret_cast operator:

Base class

The line:
virtual double functionX() const = 0;
in a class definition indicates that the class is probably a:

case 1:

Which of the following is correct when labeling cases in a switch structure?

::

A class-scope variable hidden by a block-scope variable can be accessed by preceding the variable name with the class name followed by:

Make C++ an open source programming language.

Which of the following is not a goal stated by the creator of C++ for the new C++ standard?

It always knows the size of the built-in array that is being passed

Which of the following is false about a function to which a built-in array is being passed?

Program control

Specifying the order in which statements are to be executed in a computer program is called:

setw

Which of the following is a parameterized stream manipulator used to format output?

unsigned int

The rand function generates a data value of the type

std::cout << "\"C++ is fun\"";

Which of the following statements would display the phrase "C++ is fun"?

The postfix increment operator typically returns a temporary object that contains the original value of the object before the increment occurred.

Because the postfix increment operator returns objects by value and the prefix increment operator returns objects by reference

To reference a scoped enum constant, you must qualify the constant with the scoped enum's type name and the scope-resolution operator (:), as in MaritalStatus:SINGLE

[C++11] Which of the following statements about scoped enumerations is false?

#NAME?

[C++11] In C++11, you can tell the compiler to explicitly generate the default version of a default constructor, copy constructor, move constructor, copy assignment operator, move assignment operator or destructor by following the special member function'

++

Which of the following can have a pointer as an operand?

All of the above are true

Which of the following statements is true?

It automatically destroys the object after main is exited.

Which of the following is false about the new operator and the object for which it allocates memory?

if (!(num - 65))

The expression if (num != 65) cannot be replaced by:

int total;

Which of the following is a variable declaration statement?

It takes the second element, and if it's less than the first element, it swaps it with the first element

Which of the following best describes the first iteration of an insertion sort?

istream, ostream and iostream are derived from ifstream, ofstream and fstream

Which of the following is not true about files?

class subclass : private superClass

To declare class subClass a privately derived class of superClass one would write

Classes and objects

The relationship between function templates and function-template specializations is most similar to the relationship between

Hello

Assuming that text is a variable of type string, what till be the contents of text after the statement cin>>text, is executed if the user types Hello World! then presses Enter?

Information in the memory unknit is persistent- it is retained when the computer's power is turned off

Which of the following statements is false?

2012

Given that k is an integer array starting at location 2000, kPtr is a pointer to k and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to?

A function is defined before it is first invoked

A function prototype can always be omitted when:

+

For which of the following operators does C++ not specify the order of evaluation of its operands?

Failure of the loop continuation test

Recursion is to the base case as iteration is to what:

Zero references to their class

Abstract classes do not necessarily have

True

In a linear search, it is just as likely that the value being searched will be found in the first element as the last

Programmers generally prefer high-level I/O to low-level I/O

Select the correct statement regarding C++ I/O streams

do...while

Which of the following is a repetition structure?

inputStream.tie(0)

Untying an input stream, inputStream, from an output stream, outputStream, is done with the function call

Command-line arguments

A string array is commonly used for:

The built-in array parameter can be preceded by the const qualifier

To prevent modification of a built-in array's values when you pass the built-in array to a function

n is a constant pointer to nonconstant data

Which of the following best describes the array name n in the delcaration int n[10]?