Object Oriented Programming Final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Any constructor that takes no arguments is called a

default constructor

Choosing meaningful identifiers makes a program

self-documenting

Stream insertion operator

<<

argument in parentheses

Parameterized stream manipulator

Microsoft developed the ______, consisting of a graphical user interface built on top of DOS

Windows operating system

escape character

\

Windows is a ______ operating system—it's controlled by Microsoft exclusively.

proprietary

Design patterns

proven architectures for constructing flexible and maintainable object-oriented software

Each class can provide one or more _____ that can be used to initialize an object of the class when the object is created

constructors

Only one other way to connect control statements—called

control-statement nesting

Control statements are attached to one another by connecting the exit point of one to the entry point of the next Called

control-statement stacking

standard output stream

cout

A default constructor: a. Is a constructor that must receive no arguments. b. Is the constructor generated by the compiler when no constructor is provided by the programmer. c. Does not perform any initialization. d. Both (a) and (b).

d

A variable that can have values only in the range 0 to 65535 is a: a. Four-byte int. b. Four-byte unsigned int. c. Two-byte int. d. Two-byte unsigned int.

d

All of the following are reasons to use recursion except: a. An iterative solution is not apparent. b. The resulting program is easier to debug. c. It more naturally mirrors the problem. d. It maximizes execution performance.

d

All of the following can cause a fatal execution-time error except: a. Dereferencing a pointer that has not been assigned to point to a specific address. b. Dereferencing a pointer that has not been initialized properly. c. Dereferencing a null pointer. d. Dereferencing a variable that is not a pointer.

d

An error occurs if: a. A non-reference, non-const, primitive data member is initialized in the member initialization list. b. An object data member is not initialized in the member initialization list. c. An object data member does not have a default constructor. d. An object data member is not initialized in the member initialization list and does not have a default constructor.

d

Dividing by zero results in a

fatal runtime error

Release candidates

feature complete and bug free and ready for use by the community

(UML)The solid circle surrounded by a hollow circle that appears at the bottom of the activity diagram represents the

final state

Variables of type ___ represent single-precision floating-point numbers and have seven significant digits on most of today's systems.

float

One of the most important mechanisms for computer science students to understand is the

function call stack (or program execution stack).

function call stack (or program execution stack) supports the

function call/return mechanism.

The first line of a function definition is commonly called the

function header

several functions of the same name to be defined, as long as they have different signatures

function overloading

a declaration of a function that tells the compiler the function's name, its return type and the types of its parameters

function prototype

Labels (identifiers followed by a colon such as start: or a case label in a switch statement) are the only identifiers with

function scope

The portion of a function prototype that includes the name of the function and the types of its arguments is called the

function signature or simply the signature

The only identifiers with ___ are those used in the parameter list of a function prototype.

function-prototype scope

Library function ____ reads a line of text into a string.

getline

Sometimes functions are not members of a class. Called

global functions

An identifier declared outside any function or class has

global namespace scope

Record

group of related fields

File

group of related records

A computer consists of various devices referred to as

hardware

Output unit/Output device

hardware that gives the user feedback

.h filename extension—known as a

header

Smart pointers

help you avoid errors associated with traditional pointers.

Ajax

helps Internet-based applications perform like desktop applications

A variable name is any valid ____ that is not a keyword

identifier

The _____ allows a program to take alternative action based on whether a condition is true or false.

if statement

Multi-core processor

implements multiple processors on a single integrated-circuit chip

Sentinel-controlled repetition is often called

indefinite repetition

PHP

object-oriented , "open-source" "scripting" language supported by a community of users and developers and is used by numerous websites

statements enable you to specify that the next statement to execute may be other than the next one in sequence

transfer of control

The compiler encodes each function identifier with the types of its parameters (sometimes referred to as name mangling or name decoration) to enable

type-safe linkage.

Fundamental types

types such as int, double, and char

access a global variable when a local variable of the same name is in scope

unary scope resolution operator (::)

Functions in the same scope must have

unique signatures

Regular expressions

used to match specific character patterns in text

Functions you write are referred to as

user-defined functions

The compiler does not automatically know what type GradeBook is—it's a

user-defined type

In industrial-strength code, always

validate all inputs

escape sequence

when another character follows a backslash

Loader

which takes the executable image from disk and transfers it to memory

An activity diagram models the ____ of a portion of a software system.

workflow (also called the activity)

an alias for its corresponding argument in a function call.

reference parameter

several storage-class specifiers that determine a variable's storage duration:

register, extern, mutable and static.

Software as a Service (SaaS)

the software runs on servers elsewhere on the internet

Hypertext Transfer Protocol Secure (HTTPS) is

the standard for transferring encrypted data on the web

Software Development Kits (SDKs)

the tools and documentation developers use to program applications

Input unit/Input device

A device that accepts data to be stored in memory

Open-source software

A software development style that departs from the proprietary development that dominated software's early years.

Packet switching

A technique in which digital data was sent in small bundles called packets.

An uninitialized variable contains a ____—the value last stored in the memory location reserved for that variable

"garbage" value (also called an undefined value)

The combined set of protocols is now commonly called

TCP/IP

The protocol (i.e., set of rules) for communicating over the ARPANET became known as

TCP—the Transmission Control Protocol

contains the return address that the called function needs in order to return to the calling function

a stack frame or an activation record

Counter-controlled repetition requires

-the name of a control variable (or loop counter) -the initial value of the control variable -the loop-continuation condition that tests for the final value of the control variable (i.e., whether looping should continue) -the increment (or decrement) by which the control variable is modified each time through the loop.

A function prototype (also called a function declaration) tells the compiler

-the name of a function -the type of data returned by the function -the number of parameters the function expects to receive -the types of those parameters and -the order in which the parameters of those types are expected.

ARPA proceeded to implement the _____, which eventually evolved into today's _____.

ARPANET; Internet

runtime errors (execution-time errors)

An error that occurs during the execution of a program. (divided by 0)

Translator programs called _______ convert high-level language programs into machine language.

compilers

Fields

composed of characters or bytes

_____ were developed to convert early assembly-language programs to machine language.

Assemblers

The ____ are free, open-source libraries created by members of the C++ community.

Boost C++ Libraries

Central processing unit (CPU)

Brain of the computer that performs instructions defined by software

Most C++ programmers take advantage of the rich collections of classes and functions in the

C++ Standard Library.

can be used to force the averaging calculation to produce a floating-point numeric result

Cast operator

Arithmetic and logic unit

Designed to perform mathematical operations

a symbolic integer constant defined in the <iostream> header file

EOF

is an artificial and informal language that helps you develop algorithms

Pseudocode (or "fake" code)

Android

Fastest growing mobile and smartphone operating system; open source and free

In 1989, Tim Berners-Lee of CERN (the European Organization for Nuclear Research) began to develop a technology for sharing information via hyperlinked text documents—called the

HyperText Markup Language (HTML).

ARPA accomplished this with the development of_______, truly creating a network of networks, the current architecture of the Internet.

IP—the Internet Protocol

Comma-separated list

If more than one name is declared in a declaration, the names are separated by commas

______ is crucial to good software engineering.

Information hiding

define and standardize the ways in which things such as people and systems interact with one another

Interfaces

_______ were developed to execute high-level language programs directly (without the need for compilation), although more slowly than compiled programs.

Interpreter programs

the last item pushed (inserted) is the first item popped (removed)

Last-in, first-out (LIFO) data structures

enables you to use one syntax to initialize a variable of any type

List initialization (also called uniform initialization)

Bytes

Made up of 8 bits; represents a single character

appear between a constructor's parameter list and the left brace that begins the constructor's body

Member initializers

_______ allows you to implement an object-oriented design as a working system.

Object-oriented programming (OOP)

Ada

Pascal based language

By convention, the name of a user-defined class begins with a capital letter, and for readability, each subsequent word in the class name begins with a capital letter. Often referred to as

Pascal case

______ such as the popular web languages JavaScript and PHP are processed by interpreters.

Scripting languages

Operating Systems

Software systems that make using computers more convenient for users, application developers and system administrators.

specifies that the value of each bool expression should be displayed as either the word "true" or the word "false."

Stream manipulator boolalpha (a sticky manipulator)

_____ is now the most widely used graphical scheme for modeling object-oriented systems.

The Unified Modeling Language (UML)

by enclosing the body statements in a pair of braces, { }, creating what's called a

compound statement or a block

Computers process data under the control of sequences of instructions called

computer programs

An uninitialized local variable contains: a. The value last stored in the memory location reserved for that variable. b. No value. c. A value of zero. d. A randomly assigned value.

a

escape sequence for newline

\n

A class-scope variable hidden by a block-scope variable can be accessed by preceding the variable name with the class name followed by: a. :: b. : c. . d. ->

a

A double subscripted array declared as array<array<int, 5>, 3> values; has how many elements? a. 15 b. 13 c. 10 d. 8

a

A function prototype does not have to: a. Include parameter names. b. Terminate with a semicolon. c. Agree with the function definition. d. Match with all calls to the function.

a

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. A nonconstant pointer to nonconstant data. b. A nonconstant pointer to constant data. c. A constant pointer to nonconstant data. d. A constant pointer to constant data.

a

A string array is commonly used for: a. Command-line arguments. b. Storing an extremely long string. c. Storing multiple copies of the same string. d. Displaying floating-point numbers to the screen.

a

An activation record will be popped off the function call stack whenever: a. A function returns control to its caller. b. A function calls another function. c. A function calls itself. d. A function declares a local variable.

a

special value used to indicate "end of data entry" called

a sentinel value (also called a signal value, a dummy value or a flag value)

Assume that t is an object of class Test, which has member functions a(), b(), c() and d(). If the functions a(), b() and c() all return references to an object of class Test (using the dereferenced this pointer) and function d() returns void, which of the following statements will not produce a syntax error: a. t.a().b().d(); b. a().b().t; c. t.d().c(); d. t.a().t.d();

a

Assume that the function call operator() is overloaded for data type String in the usual sense of selecting a substring from a larger string. For a String object string1 with the character string "ABCDEFGHI", what string does string1(4, 2) return? a. "EF" b. "EFGHI" c. "CDEF" d. "CD"

a

Assuming that the string object text contains the string "Hello!!! ", the "expression text.substr( 2 , 5 ) would return a string object containing the string: a. "llo!! ". b. "llo! ". c. "ello! ". d. "ello".

a

Assuming the following is the beginning of the constructor definition for class BasePlus-CommissionEmployee which inherits from class Point: BasePlusCommissionEmployee::BasePlusCommissionEmployee(string first, string last, string ssn, double sales, double rate, double salary) : CommissionEmployee(first, last, ssn, sales, rate) The line beginning with a colon(:) a. Invokes the CommissionEmployee constructor with arguments. b. Causes a compiler error. c. Is unnecessary because the CommissionEmployee constructor is called automatically. d. Indicates inheritance.

a

Base class constructors and assignment operators: a. Are not inherited by derived classes. b. Should not be called by derived class constructors and assignment operators. c. Can be inherited by derived classes, but generally are not. d. Can call derived-class constructors and assignment operators.

a

Comparing pointers and performing pointer arithmetic on them is meaningless unless: a. They point to elements of the same array. b. You are trying to compare and perform pointer arithmetic on the values to which they point. c. They point to arrays of equal size. d. They point to arrays of the same type.

a

Consider the following code, assuming that x is an int with an initial value of 12 if( x = 6 ) cout << x; What is the output? a. 6 b. 12 c. Nothing. d. A syntax error is produced.

a

Given the class definition: class CreateDestroy { public: CreateDestroy() {cout << "constructor called, ";} ~CreateDestroy() {cout << "destructor called, ";} }; What will the following program output? int main() { for (int i = 1; i <= 2; ++i) { CreateDestroy cd; } return 0; } a. constructor called, destructor called, constructor called, destructor called, b. constructor called, constructor called, c. constructor called, constructor called, destructor called, destructor called, d. Nothing.

a

In order to calculate the __________ of an array of values, the array values must first be summed. a. Average. b. Minimum. c. Maximum. d. Distribution.

a

In the UML, the top compartment of the rectangle modeling a class contains: a. The class's name. b. The class's attributes. c. The class's behaviors. d. All of the above.

a

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: a. *this.x b. (*this).x c. x d. None of the above are equivalent.

a

Labels are the only identifiers with: a. Function scope. b. File scope. c. Block scope.

a

Member access specifiers (public and private) can appear: a. In any order and multiple times. b. In any order (public first or private first) but not multiple times. c. In any order and multiple times, if they have brackets separating each type. d. Outside a class definition.

a

Overloaded functions must have: a. Different parameter lists. b. Different return types. c. The same number of parameters. d. The same number of default arguments.

a

Pseudocode normally does not include: a. Declarations. b. Input/output. c. Algorithms. d. Control structures.

a

Referencing elements outside the array bounds with the [] operator: a. Can result in changes to the value of an unrelated variable. b. Is impossible because C++ checks to make sure it does not happen. c. Is a syntax error. d. Enlarges the size of the array.

a

Suppose the unary ! operator is an overloaded member function of class String. For a String object s, which function call is generated by the compiler when it finds the expression !s? a. s.operator!() b. s.operator!(default_value1, default_value2,...) c. operator!(s) d. A compiler error results because no arguments are given.

a

Suppose you have a programmer-defined data type Data and want to overload the << operator to output your data type to the screen in the form cout << dataToPrint; and allow cascaded function calls. The first line of the function definition would be: a. ostream& operator<<(ostream& output, const Data& dataToPrint) b. ostream operator<<(ostream& output, const Data& dataToPrint) c. ostream& operator<<(const Data& dataToPrint, ostream& output) d. ostream operator<<(const Data& dataToPrint, ostream& output)

a

The code fragment: Increment::Increment(int c, int i) : increment (i) { count = c; } does not cause any compilation errors. This tells you that: a. count must be a non-const variable. b. count must be a const variable. c. increment must be a non-const variable. d. increment must be a const variable.

a

The conditional operator (?:): a. Is the only ternary operator in C++. b. Is a unary operator. c. Associates from left to right. d. Accepts two operands.

a

The correct function name for overloading the addition (+) operator is: a. operator+ b. operator(+) c. operator:+ d. operator_+

a

The rand function generates a data value of the type: a. unsigned int. b. int. c. long int. d. short int.

a

The unary scope resolution operator is used: a. To access a global variable when a local variable of the same name is in scope. b. To access any variable in an outer block when a local variable of the same name is in scope. c. To access a global variable when it is out of scope. d. To access a local variable with the same name as a global variable.

a

To declare class subClass a privately derived class of superClass one would write: a. class subclass : private superClass b. class subclass :: private superClass c. class subclass <private superClass> d. class subclass inherits private superClass

a

Utility functions: a. Are private member functions that support operations of the class's other member functions. b. Are part of a class's interface. c. Are intended to be used by clients of a class. d. Are a type of constructor.

a

Variables are also known as: a. lvalues, but can be used as rvalues. b. lvalues, and cannot be used as rvalues. c. rvalues, and cannot be used as lvalues. d. Constant variables.

a

When an object of a derived class is instantiated, the __________ constructor initializes the _________ members. a. Base class, base class. b. Derived class, base class. c. Base class, derived class. d. Derived class, public.

a

Which of the following can have a pointer as an operand? a. ++ b. *= c. % d . /

a

Which of the following expressions returns the trigonometric sine of x? a. sin( x ). b. sine( x ). c. trig_sin( x ). d. trig_sine( x ).

a

Which of the following is false about a function to which a built-in array is being passed? a. It always knows the size of the built-in array that is being passed. b. It is being passed the address of the first element in the built-in array. c. It is able to modify the values stored in the built-in array. d. The built-in array's name is used as an argument in the function call.

a

Which of the following is false? a. A string can be defined to store any data type. b. Class string provides bounds checking in its member function at. c. Class string's overloaded [] operator returns a vector element as an rvalue or an lvalue, depending on the context. d. An exception is thrown if the argument to string's at member function is an invalid subscript.

a

Which of the following is most likely a base class of the other three? a. automobile. b. convertible. c. miniVan. d. sedan.

a

Which of the following is not a correct way to initialize a built-in array? a. int n[5]{0, 7, 0, 3, 8, 2}; b. int n[]{0, 7, 0, 3, 8, 2}; c. int n[5]{7}; d. int n[5]{9, 1, 9};

a

Which of the following is not true of static local variables? a. They are accessible outside of the function in which they are defined. b. They retain their values when the function in which they are defined terminates. c. They are initialized to zero if not explicitly initialized by the programmer. d. They can be of type int.

a

Which of the following lines would be the prototype for an overloaded cast operator function that converts an object of user-defined type Time into a double? a. Time::operator double() const; b. Time::static_cast double() const; c. Time::operator_cast(double) const; d. Time::double() const;

a

Which of the following operators cannot be overloaded? a. The . operator. b. The -> operator. c. The & operator. d. The [ ] operator.

a

Which of the following statements about friend functions and friend classes is false? a. A class can either grant friendship to or take friendship from another class using the friend keyword. b. A friend declaration can appear anywhere in a class definition. c. A friend of a class can access all of its private data member and member functions. d. The friendship relationship is neither symmetric nor transitive.

a

Which of the following statements is false (assume we're referring to class Time)? a.Often a class's interface and implementation will be created and compiled by one programmer and used by a separate programmer who implements the client code that uses the class. b. To hide the class's member-function implementation details, the class-implementation programmer would provide the client-code programmer with the header Time.h (which specifies the class's interface and data members) and the Time object code (i.e., the machine-code instructions that represent Time's member functions). c. The client-code programmer is not given Time.cpp, so the client remains unaware of how Time's member functions are implemented. d. The client-code programmer needs to know only Time's interface to use the class and must be able to link its object code.

a

Which statement is false? a. Based on whether an operator is implemented as a member function or as a non-member function, the operator is used differently in expressions. b. When an operator function is implemented as a member function, the leftmost (or only) operand must be an object (or a reference to an object) of the operator's class. c. Operator member functions of a specific class are called (implicitly by the compiler) only when the left operand of a binary operator is specifically an object of that class, or when the single operand of a unary operator is an object of that class. d. Another reason why you might choose a non-member function to overload an operator is to enable the operator to be commutative.

a

You can sort an array with the Standard Library's: a. sort function. b. sort_array function. c. array_sort function. d. None of the above.

a

protected base class members cannot be accessed by: a. Functions that are neither friends of the base class, derived-class member functions nor friends of a derived class. b. friends of the base class. c. Functions that are not derived-class member functions. d. friends of derived classes.

a

Hypertext Transfer Protocol (HTTP)

a communications protocol used to send information over the web.

A variable is

a location in the computer's memory where a value can be stored for use by a program.

A preprocessing directive is

a message to the C++ preprocessor.

Web 2.0

a new generation of internet services that emphasize online collaboration and sharing

A nonfatal logic error allows

a program to continue executing, but usually produces incorrect results

A fatal logic error causes

a program to fail and terminate prematurely

each class is modeled in a UML class diagram as

a rectangle with three compartments.

A keyword is

a word in code that is reserved by C++ for a specific use.

The ___ may be repeated, but this is unnecessary and can be confusing.

access specifiers public and private

get functions are also sometimes called

accessors

procedure for solving a problem in terms of the actions to execute and the order in which the actions execute

algorithm

Nonfatal runtime errors

allow programs to run to completion, often producing incorrect results

World Wide Web

allows you to locate and view multimedia-based documents on almost any subject over the Internet.

Cloud computing

allows you to use software, hardware and information stored in the "cloud"

LAMP

an acronym for the set of open-source technologies that many developers use to build web applications; stands for Linux, Apache, MySQL, and PHP

Database

an electronic collection of data that's organized for easy access and manipulation

Moore's Law is

an observation made by Intel co-founder Gordon Moore in 1965. He noticed that the number of transistors per square inch on integrated circuits had doubled every year since their invention.

Using a loop's counter control variable in a calculation after the loop often causes a common logic error called

an off-by-one error

Platform as a Service (PaaS)

another capability of cloud computing

Web 2.0 embraces an ______—a design that encourages user interaction and community contributions.

architecture of participation

An important feature of function prototypes is

argument coercion

A function call supplies values—called ____—for each of the function's parameters.

arguments

English-like abbreviations to represent elementary operations. These abbreviations formed the basis of ______.

assembly languages

(*max)(num1, num2, num3);: a. Is the heade for function max. b. Is a call to the function pointed to by max. c. Is the prototype for function max. d. Is a declaration of a pointer to a function called max.

b

: In a typical nested for loop (not a range-based for loop) used to process a two-dimensional array, following the end of each execution of the inner for loop: a. The outer for loop initializes its counter variable. b. The outer for loop increments its counter variable. c. The inner for loop initializes its counter variable. d. The inner for loop increments its counter variable.

b

A client changing the values of private data members is: a. Only possible by calling private member functions. b. Possible using public functions and references. c. Never possible. d. Only possible if the private variables are not declared inside the class.

b

A copy constructor must receive its argument by reference because: a. Otherwise the constructor will only make a copy of a pointer to an object. b. Otherwise infinite recursion occurs. c. The copy of the argument passed by value has function scope. d. The pointer needs to know the address of the original data, not a temporary copy of it.

b

A copy constructor: a. Is a constructor with only default arguments. b. Is a constructor that initializes a newly declared object to the value of an existing object of the same class. c. Is a constructor that takes no arguments. d. None of the above.

b

A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is: a. A nonconstant pointer to nonconstant data. b. A nonconstant pointer to constant data. c. A constant pointer to nonconstant data. d. A constant pointer to constant data.

b

An identifier's storage class: a. Determines whether an identifier is known only in the current source file or in any source file with proper declarations. b. Determines the period during which that identifier exists in memory. c. Determines where the identifier can be referenced in a program. d. All of the above.

b

Conversion constructors: a. Can have multiple arguments. b. Can convert between user-defined types. c. Are implicitly defined by the compiler if not explicitly written by the programmer. d. Cannot convert built-in types to user defined types.

b

Every object of the same class: a. Gets a copy of every member function and member variable. b. Gets a copy of every member variable. c. Gets a copy of every member function. d. Shares pointers to all member variables and member functions.

b

For a non-constant member function of class Test, the this pointer has type: a. const Test * b. Test * const c. Test const * d. const Test * const

b

From most restrictive to least restrictive, the access modifiers are: a. protected, private, public b. private, protected, public c. private, public, protected d. protected, public, private

b

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? a. Age. b. The President. c. Place of birth. d. Favorite food.

b

If a member function of a class already provides all or part of the functionality required by a constructor or another member function then: a. Copy and paste that member function's code into this constructor or member function. b. Call that member function from this constructor or member function. c. That member function is unnecessary. d. This constructor or member function is unnecessary.

b

If the line: friend class A; appears in class B, and the line: friend class B; appears in class C, then: a. Class A is a friend of class C. b. Class A can access private variables of class B. c. Class C can call class A's private member functions. d. Class B can access class A's private variables.

b

Member function definitions: a. Always require the scope resolution operator (::). b. Require the scope resolution operator only when being defined outside of the definition of their class. c. Can use the scope resolution operator anywhere, but become public functions. d. Must use the scope resolution operator in their function prototype.

b

Pointers cannot be used to: a. Contain memory addresses. b. Reference values directly. c. Pass an argument by reference. d. Manipulate dynamic data structures.

b

The assignment operator (=) can be used to: a. Test for equality. b. Copy data from one object to another. c. Compare two objects. d. Copy a class.

b

The conventional way to distinguish between the overloaded preincrement and postincrement operators (++) is: a. To assign a dummy value to preincrement. b. To make the argument list of postincrement include an int. c. To have the postincrement operator call the preincrement operator. d. Implicitly done by the compiler.

b

The inline keyword: a. Increases function-call overhead. b. Can reduce a function's execution time but increase program size. c. Can decrease program size but increase the function's execution time. d. Should be used with all frequently used functions.

b

The is-a relationship represents. a. Composition. b. Inheritance. c. Information Hiding. d. A friend.

b

To prevent modification of a built-in array's values when you pass the built-in array to a function: a. The built-in array must be declared static in the function. b. The built-in array parameter can be preceded by the const qualifier. c. A copy of the built-in array must be made inside the function. d. The built-in array must be passed by reference.

b

Using square brackets ([]) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking. a. Does not, does not. b. Does not, does. c. Does, does not. d. Does, does.

b

What does the following statement declare? int *countPtr, count; a. Two int variables. b. One pointer to an int and one int variable. c. Two pointers to ints. d. The declaration is invalid.

b

When using exception handling, place any code that might throw an exception in a __________. a. catch block b. try statement. c. throw block. d. what statement.

b

Which of the following does not display correct if answer is equal to 7 and incorrect if answer is not equal to 7? a. if ( answer == 7 ) cout << "correct"; else cout << "incorrect"; b. cout << answer == 7 ? "correct" : "incorrect"; c. cout << ( answer == 7 ? "correct" : "incorrect" ); d. answer == 7 ? cout << "correct" : cout << "incorrect";

b

Which of the following is not a correct way to initialize the array named n? a. array<int, 5> n{0, 7, 0, 3, 8}; b. array<int, 5> n{0, 7, 0, 3, 8, 2}; c. array<int, 5> n{7}; d. array<int, 5> n{9, 1, 9};

b

Which of the following is not one the rules for forming structured programs? a. Begin with the "simplest activity diagram." b. Any transition arrow can be reversed. c. Any action state can be replaced by two action states in sequence. d. Any action state can be replaced by any control statement.

b

Which of the following is true? a. Assigning a double value to an int does not lose any data. b. For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss. c. For fundamental-type variables, list-initialization syntax allows narrowing conversions that could result in data loss. d. None of the above.

b

Which of the following is true? a. You can initialize data members of a class only in the class's constructor. b. C++11 allows you to provide a default value for a data member when you declare it in the class declaration. c. You cannot initialize data members of a class. d. None of the above

b

Which of the following statements about inheriting base class constructors is false? a. To inherit a base class's constructors, you write the following line of code in the derived class definition (BaseClass is the base class's name): using BaseClass::BaseClass; b. If an inherited base-class constructor has default arguments, the line of code in Part (a) causes the compiler to generate a derived-class constructor with the same default arguments. c. By default, each inherited constructor has the same access level (public, protected or private) as its corresponding base-class constructor. d. If the derived class does not explicitly define constructors, the compiler generates a default constructor in the derived class—even if it inherits other constructors from its base class.

b

Which of the following statements is false? a. The concepts of icons, menus and windows were originally developed by Xerox PARC. b. Windows is an open source operating system. c. The software that contains the core components of the operating system is called the kernel. d. Linux source code is available to the public for examination and modification.

b

Using multiple stream insertion operators (<<) in a single statement is referred to as

concatenating, chaining or cascading stream insertion operations

Which of the following statements is false? a. You can overload a classes constructors. b. There is no mechanism in C++ for a constructor to call another constructor in the same class. c. Just as a constructor can call a class's other member functions to perform tasks, C++11 allows constructors to call other constructors in the same class. d. To overload a constructor, provide in the class definition a prototype for each version of the constructor, and provide a separate constructor definition for each overloaded version.

b

Which statement about exception handling is false? a. Call the exception object's what member function to get the error message that's stored in the exception object. b. Bounds checking is performed at execution time with vector member function at, and if a subscript is within the bounds of the array, the member function throws an out_of_bounds exception. c. The catch block contains the code that handles an exception if one occurs. d. None of the above statements in false.

b

Which statement about operator overloading is false? a. New operators can never be created. b. Certain overloaded operators can change the number of arguments they take. c. The precedence of an operator cannot be changed by overloading. d. Overloading cannot change how an operator works on built-in types.

b

cin.getline(superstring, 30); is equivalent to which of the following? a. cin.getline(superstring, 30, '\0'); b. cin.getline(superstring, 30, '\n'); c. cin.getline(superstring, 30, '\s'); d. cin.getline(superstring, 30, '\t');

b

static member functions: a. Can use the this pointer. b. Can access only other static member functions and static data members. c. Cannot be called until an object of their class is instantiated. d. Can be declared const as well.

b

y and z are user-defined objects and the += operator is an overloaded member function. The operator is overloaded such that y += z adds z and y, then stores the result in y. Which of the following expressions is always equivalent to y += z? a. y = y operator+= z b. y.operator+=(z) c. y = y + z d. y operator+=(y + z)

b

The = operator and the + operator are called ____ because each has two operands.

binary operators

Identifiers declared inside a block have ___, which begins at the identifier's declaration and ends at the terminating right brace (}) of the block in which the identifier is declared.

block scope

A class's functions can throw exceptions, such as __________to indicate invalid data. a. invalid_data b. bad_data c. invalid_argument d. bad_argument

c

A pointer can not be assigned to: a. Another pointer of the same type without using the cast operator. b. A pointer to void without using the cast operator. c. A pointer of a type other than its own type and void without using the cast operator. d. Any other pointer by using the cast operator.

c

A string array: a. Stores an actual string in each of its elements. b. Can only provide access to strings of a certain length. c. Is actually an array of pointers. d. Is always less memory efficient than an equivalent double-subscripted array.

c

All of the following are true of functions except: a. They define specific tasks that can be used at many points in a program. b. A function call must specify the name and arguments of the function. c. The definition of a function usually is visible to other functions. d. The implementation of a function is hidden from the caller.

c

An array is not: a. A consecutive group of memory locations. b. Subscripted by integers. c. Made up of different data types. d. None of the above.

c

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): a. operator+ must be a member function of the class from which the objects are instantiated. b. operator+ must be a non-member function. c. 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. d. The + operator cannot be overloaded to be commutative.

c

Assume that the array named items contains the integer values 0, 2, 4, 6 and 8. Which of the following set of statements uses the range-based for loop to display each value in items? a. for (int i = 0; i <items.size(); ++i) { cout <<items[i] <<endl; } b. for (int item : items) { cout <<items[item] <<endl; } c. for (int item : items) { cout <<item <<endl; } d. for (int item : items.size()){ cout <<item <<endl; }

c

Assuming that GradeBook.h is found in the current directory and the iostream header file is found in the C++ Standard Library header file directory, which of the following preprocessor directives will fail to find its desired header file? a. #include <iostream> b. #include "iostream" c. #include <GradeBook.h> d. #include "GradeBook.h"

c

Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array? a. *(tPtr + 3) b. tPtr[3] c. &t[3] d. *(t + 3)

c

Assuming the definition, class BasePlusCommissionEmployee : public CommissionEmployee which of the following is false? a. The colon (:) in the header of the class definition indicates inheritance. b. The keyword public indicates the type of inheritance. c. All the public and protected members of class BasePlusCommissionEmployee are inherited as public and protected members, respectively, into class CommissionEmployee. d. CommissionEmployee is the base class and BasePlusCommissionEmployee is the derived class.

c

Constant variables: a. Can be assigned values in executable statements. b. Do not have to be initialized when they are declared. c. Can be used to specify array sizes, thereby making programs more scalable. d. Can be used to specify array sizes, but this makes programs harder to understand.

c

Converting from type ________ to type ________ will result in the loss of data. a. bool, char. b. float, double. c. int, char. d. short, long.

c

Enumeration constants: a. Must have unique integer values. b. Can be assigned other values once they've been defined. c. Must have unique identifiers. d. Are declared using the keyword const.

c

For operators overloaded as non-static member functions: a. Binary operators can have two arguments and unary operators can have one. b. Both binary and unary operators take one argument. c. Binary operators can have one argument, and unary operators cannot have any. d. Neither binary nor unary operators can have arguments.

c

Given a built-in array of ints named values, which of the following statements would sort the array? a. sort(values.begin(), values.end()); b. sort(values.array_begin(), values.array_end()); c. sort(begin(values), end(values)); d. sort(array_begin(values), array_end(values));

c

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. 2003 b. 2006 c. 2012 d. 2024

c

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: a. Only to the current value being displayed. b. Only to outputs displayed in the current statement. c. Until explicitly set to a different setting. d. Until the output buffer is flushed.

c

Recursion is to the base case as iteration is to what: a. The counter. b. A repetition structure. c. Failure of the loop continuation test. d. A selection structure.

c

Returning references to non-const, private data: a. Allows private functions to be modified. b. Is only dangerous if the binary scope resolution operator (::) is used in the function prototype. c. Allows private member variables to be modified, thus "breaking encapsulation." d. Results in a compiler error.

c

Specifying the order in which statements are to be executed in a computer program is called: a. An algorithm. b. Transfer of control. c. Program control. d. Pseudocode.

c

The & operator can be applied to: a. constants. b. string literals. c. lvalues. d. rvalues.

c

The array subscript operator [], when overloaded, cannot: a. Be used with linked list classes. b. Take a float as an operand. c. Take multiple values inside (e.g., [4,8]). d. Take user-defined objects as operands.

c

The code ", have a great day!"s is an example of ________: a. a compilation error b. a string iterator c. a string-object literal. d. string interpolation.

c

The delete [] operator: a. Can terminate the program. b. Must be told which destructor to call when destroying an object. c. Can delete an entire array of objects declared using new. d. Is called implicitly at the end of a program.

c

The prototypes of overloaded cast operator functions do not: a. Specify the type they convert to. b. Specify the type that is being converted. c. Specify a return type. d. Need to be defined inside the class whose objects are being converted.

c

The type of function a client would use to check the balance of a bank account would be: a. A utility function. b. A predicate function. c. An access function. d. A constructor.

c

Three of the following expressions have the same value. Which of the following expressions has a value different from the others'? a. *&ptr b. &*ptr c. *ptr d. ptr

c

To prevent class objects from being copied: a. Make the overloaded assignment operator private. b. Make the copy constructor private. c. Both (a) and (b). d. None of the above.

c

Variables defined inside a member function of a class have: a. File scope. b. Class scope. c. Block scope. d. Class or block scope, depending on whether the binary scope resolution operator (::) is used.

c

When a client code programmer uses a class whose implementation is in a separate file from its interface, that implementation code is merged with the client's code during the: a. Programming phase. b. Compiling phase. c. Linking phase. d. Executing phase.

c

When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to: a. int a b. int &a c. int *a d. No conversion is necessary.

c

When composition (one object having another object as a member) is used: a. The host object is constructed first and then the member objects are placed into it. b. Member objects are constructed first, in the order they appear in the host constructor's initializer list. c. Member objects are constructed first, in the order they are declared in the host's class. d. Member objects are destructed last, in the order they are declared in the host's class.

c

When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________? a. protected, private b. public, private c. protected, protected d. public, protected

c

When should base class members be declared protected? a. When all clients should be able to access these members. b. When these members are used only by member functions of this base class. c. When these members should be available only to derived classes (and friends), but not to other clients. d. The protected access specified should never be used.

c

Which of the following best describes the array name n in the declaration int n[10];? a. n is a nonconstant pointer to nonconstant data. b. n is a nonconstant pointer to constant data. c. n is a constant pointer to nonconstant data. d. n is a constant pointer to constant data.

c

Which of the following does the C++ compiler not examine in order to select the proper overloaded function to call? a. Types and order of the arguments in the function call. b. The number of arguments in the function call. c. The return type of the function. d. It examines all of the above.

c

Which of the following gives the number of elements in the array int r[10]? a. sizeof r b. sizeof (*r) c. sizeof r / sizeof (int) d. sizeof (*r) / sizeof (int)

c

a state in which the object's data member contains a valid value

consistent state

Which of the following is false for pointer-based strings? a. A string may include letters, digits and various special characters (i.e., +, -, *). b. A string in C++ is an array of characters ending in the null character ('\0'). c. String literals are written inside of single quotes. d. A string may be assigned in a declaration to either a character array or a variable of type char *.

c

Which of the following is false? a. An engine implements a random-number generation algorithm that produce pseudorandom numbers. b. A distribution controls the range of values produced by an engine, the types of those and the statistical properties of the values. c. The default range of a uniform_int_distribution is from 0 to 32767. d. C++11 provides many classes that represent various random-number generation engines and distributions.

c

Which of the following is false? a. The last element of an array has position number one less than the array size. b. The position number contained within square brackets is called a subscript. c. A subscript cannot be an expression. d. All of the above.

c

Which of the following is not a kind of inheritance in C++? a. public. b. private. c. static. d. protected.

c

Which of the following is not true of a constructor and destructor of the same class? a. They both have the same name aside from the tilde (~) character. b. They are both usually called once per object created. c. They both are able to have default arguments. d. Both are called automatically, even if they are not explicitly defined in the class.

c

Which of the following statements about a unique_ptr object is true? a. A unique_ptr is a "smart pointer" for managing dynamically allocated memory. b. When a unique_ptr goes out of scope, its destructor automatically returns the managed memory to the free store. c. You must explicitly delete the memory that's managed by a unique_ptr before the object goes out of scope. d. All of the above.

c

Which of the following statements will not produce a syntax error? a. Defining a const member function that modifies a data member of the object. b. Invoking a non-const member function on a const object. c. Declaring an object to be const. d. Declaring a constructor to be const.

c

Which situation would require the operator to be overloaded as a non-member function? a. The overloaded operator is =. b. The left most operand must be a class object (or a reference to a class object). c. The left operand is an int. d. The operator returns a reference.

c

Which statement about operator overloading is false? a. Operator overloading is the process of enabling C++'s operators to work with class objects. b. C++ overloads the addition operator (+) and the subtraction operator (-) to perform differently, depending on their context in integer, floating-point and pointer arithmetic with data of fundamental types. c. You can overload all C++ operators to be used with class objects. d. When you overload operators to be used with class objects, the compiler generates the appropriate code based on the types of the operands.

c

static data members of a certain class: a. Can be accessed only if an object of that class exists. b. Cannot be changed, even by objects of the same that class. c. Have class scope. d. Can only be changed by static member functions.

c

_____ capitalization style allows the first letter to be either lowercase or uppercase

camel case

C++ is ___ sensitive

case

Fatal runtime errors

cause programs to terminate immediately without having successfully performed their jobs

standard error system

cerr

Software reuse

changing of existing software to tailor to a programmer's needs

Digits, letters, and special symbols are known as

characters

The Unicode character set contains

characters for many of the world's languages

standard input stream

cin

In C++, we create a program unit called a ____ to house the set of member functions that perform the class's tasks.

class

C++ programs consist of pieces called _____ and _____

classes; functions

any class or function that calls the object's member functions from outside the object

client of an object

Access specifiers are always followed by a

colon

An attempt by a function, which is not a member of a particular class to access a private member of that class is a

compilation error

Forgetting to include the appropriate header when using standard library functions is a

compilation error

A syntax error occurs when the

compiler encounters code that violates C++ language rules

Syntax errors are also called

compiler errors, compiletime errors, or compilation errors

An example of a unary operator is: a. The < relational operator. b. The = assignment operator. c. The % arithmetic operator. d. The ! logical operator.

d

An explicit constructor: a. Cannot be called outside of the class it is declared in. b. Can be implicitly called by the compiler to perform a data type conversion. c. Does not initialize its class's data members. d. Must take exactly one argument.

d

Assuming the following constructor is provided for class Time explicit Time(int = 0, int = 0, int = 0); which of the following is not a valid way to initialize a Time object? a. Time t1; b. Time t2{22, 40}; c. Time t3(22, 40); d. a), b) and c) are all valid ways to initialize a Time object.

d

Because the postfix increment operator returns objects by value and the prefix increment operator returns objects by reference: a. Prefix increment has slightly more overhead than postfix increment. b. The postfix increment operator returns the actual incremented object with its new value. c. Objects returned by postfix increment cannot be used in larger expressions. d. The postfix increment operator typically returns a temporary object that contains the original value of the object before the increment occurred.

d

Consider the execution of the following for loop for (int x = 1; x < 5; increment ) cout << x + 1 << endl; If the last value printed is 5, which of the following might have been used for increment? a. x++ b. x += 1 c. ++x d. Any of the above.

d

Consider the following function: void reverse(char *string1, const char *string2) { int stringsize{sizeof(string1)/sizeof(char)}; *(string1 + stringsize - 1) = '\0'; string1 = string1 + stringsize - 2; for (; *string2 != '\0'; string1--, string2++) { *string1 = *string2; } } What technique does the function use to refer to array elements? a. Array subscript notation. b. Pointer/offset notation where the pointer is actually the name of the array. c. Pointer subscript notation. d. Pointer/offset notation.

d

Given the class definition: class CreateDestroy { public: CreateDestroy() {cout << "constructor called, ";} ~CreateDestroy() {cout << "destructor called, ";} }; What will the following program output? int main() { CreateDestroy c1; CreateDestroy c2; return 0; } a. constructor called, destructor called, constructor called, destructor called, b. constructor called, destructor called, c. constructor called, constructor called, d. constructor called, constructor called, destructor called, destructor called,

d

In regards to default arguments, which of the following is false? a. When an argument is omitted in a function call, the default value of that argument is automatically inserted by the compiler and passed in the function call. b. They must be the rightmost (trailing) arguments in a function's parameter list. c. Default values can be constants. d. Default values cannot be global variables or function calls.

d

Linear search can be used on: a. Unsorted arrays. b. Sorted arrays. c. Integer arrays. d. Any of the above.

d

Of the following, which is not a logic error? a. Not placing curly braces around the body of an if that contains two statements. b. Using == to assign a value to a variable. c. Failing to initialize counter and total variables before the body of a loop. d. Using commas instead of the two required semicolons in a for header.

d

Pointers may be assigned which of the following values? a. Any integer values. b. An address. c. nullptr. d. Both (b) and (c).

d

Select the false statement regarding inheritance. a. A derived class can contain more attributes and behaviors than its base class. b. A derived class can be the base class for other derived classes. c. Some derived classes can have multiple base classes. d. Base classes are usually more specific than derived classes.

d

The expression if ( num != 65 ) cannot be replaced by: a. if ( num > 65 || num < 65 ) b. if ( !( num == 65 ) ) c. if ( num - 65 ) d. if ( !( num - 65 ) )

d

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: a. Date Date::operator++(int) { Date temp{*this}; Increment(); return *temp; } b. Date Date::operator++(int) { Increment(); Date temp{*this}; return temp; } c. Date Date::operator++(int) { Date temp{*this}; return this; temp.Increment(); } d. Date Date::operator++(int) { Date temp{*this}; Increment(); return temp; }

d

To implicitly overload the += operator: a. Only the + operator needs to be overloaded. b. Only the = operator needs to be overloaded. c. Both the + and = operators need to be overloaded. d. The += operator cannot be overloaded implicitly.

d

To prevent class objects from being copied or assigned, you can: a. Declare as private the class's copy constructor and overloaded assignment operator. b. Declare the class's copy constructor and overloaded assignment operator with with = delete after the parameter list. c. Simply do not declare a copy constructor or assignment operator in the class. d. (a) or (b).

d

What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation: a. A nonconstant pointer to nonconstant data. b. A nonconstant pointer to constant data. c. A constant pointer to nonconstant data. d. A constant pointer to constant data.

d

Which forms of inheritance are is-a relationships? a. All forms of inheritance are is-a relationships. b. Only public and private. c. Only public and protected. d. Only public.

d

Which of the following C++ Standard Library headers does not contain a C++ Standard Library container class? a. <vector>. b. <list>. c. <stack>. d. <string>.

d

Which of the following data types can be used to represent integers? a. char b. long c. short d. All of the above.

d

Which of the following tasks cannot be performed using a range-based for loop? a. Calculating the product of all the values in an array. b. Displaying all even element values in an array. c. Incrementing the value stored in each element of the array. d. Accessing the element's subscript.

d

Which of the following does not declare a 2-by-2 array and set all four of its elements to 0? a. array<array<int,2>, 2> b; b[0][0] = b[0][1] = b[1][0] = b[1][1] = 0; b. array<array<int, 2>, 2> b = {0}; c. array<array<int, 2>, 2> b; for (auto const &row : b) { for (auto &element : row) { element = 0; } } d. All of the above initialize all four of the array elements to 0.

d

Which of the following is false about the new operator and the object for which it allocates memory? a. It calls the object's constructor. b. It returns a pointer. c. It does not require the size of the object to be explicitly specified in the new expression. d. It automatically destroys the object after main is exited.

d

Which of the following is false? a. An entire non-char array cannot be input or output at once. b. Two arrays cannot be meaningfully compared with equality or relational operators. c. Arrays cannot be assigned to one another (i.e., array1 = array2;). d. C++ ensures that you cannot "walk off" either end of an array.

d

Which of the following is false? a. The effects of break and continue statements can be achieved by structured programming techniques. b. break and continue statements can make a program perform faster than with the corresponding structured techniques. c. Many programmers feel that break and continue violate structured programming. d. You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.

d

Which of the following is false? a. To receive a list initializer as an argument to a constructor, you can declare the constructor's parameter as type list_initialier<T> where T represents the type of the values in the list initializer. b. To receive a list initializer as an argument to a constructor, you can declare the constructor's parameter as type initializer_list<T> where T represents the type of the values in the list initializer. c. It's not possible to pass a list initializer to a constructor. d. (a) and (c).

d

Which of the following is false? a. break and continue statements alter the flow of control. b. continue statements skip the remaining statements in current iteration of the body of the loop in which they are embedded. c. break statements exit from the loop in which they are embedded. d. continue and break statements may be embedded only within repetition statements.

d

Which of the following is not a disadvantage of default memberwise copy with objects containing pointers? a. Having the possibility of leaving a dangling pointer. b. Allowing both objects to point to the same dynamically allocated storage. c. Allowing the destructor of one object to be called while leaving the second pointer, to the same memory location, intact. d. Requiring the explicit overloading of the assignment operator.

d

Which of the following is not a good example of a hierarchy likely to be modeled by inheritance? a. Airplanes. b. Geometric shapes. c. Animals. d. Prime numbers.

d

Which of the following is not a valid way to pass arguments to a function in C++? a. By reference with reference arguments. b. By value. c. By reference with pointer arguments. d. By value with pointer arguments.

d

Which of the following is not included in a function's activation record? a. The return address of its caller function. b. Parameter values received from its caller. c. Local variables it has declared. d. The name of the function.

d

Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class? a. Errors are prone to be spread around. b. It is time consuming. c. It forces the system to store many physical copies of the code, creating a code-maintenance nightmare. d. All of the above are disadvantages of the "copy-and-paste" approach.

d

Which of the following is not true of a destructor? a. It performs termination housekeeping. b. It is called before the system reclaims the object's memory. c. If the programmer does not explicitly provide a destructor, the compiler creates an "empty" destructor. d. It releases the object's memory.

d

Which of the following is not true of class template vector? a. The size of a vector can be changed after it is declared. b. A vector can be assigned to another vector by using the assignment operator. c. A vector object can be initialized with a copy of another vector by invoking the copy constructor. d. A vector can store only data of type int.

d

Which of the following is not true of pointers to functions? a. They contain the starting address of the function code. b. They are dereferenced in order to call the function. c. They can be stored in arrays. d. They can not be assigned to other function pointers.

d

Which of the following operators can be overloaded as a non-member function? a. () b. [] c. += d. ==

d

Which of the following preprocessor directives does not constitute part of the preprocessor wrapper? a. #define b. #endif c. #ifndef d. #include

d

Which of the following statements about pointer initialization and values is false? a. Prior C++11, the value specified for a null pointer was 0 or NULL. b. When 0 is assigned to a pointer, it's converted to a pointer of the appropriate type. c. The value 0 is the only integer value that can be assigned directly to a pointer variable without first casting the integer to a pointer type. d. In the new standard, you should use the constant null_ptr to initialize a pointer instead of 0 or NULL.

d

Which of the following statements is false (ssume we're referring to class Time)? a. Since the interface of the class is part of the class definition in the Time.h header, the client-code programmer must have access to this file and must #include it in the client's source-code file. b. When the client code is compiled, the compiler uses the class definition in Time.h to ensure that the main function creates and manipulates objects of class Time correctly. c. The linker's output is the executable Time application that users can execute to create and manipulate a Time object. d. Compilers and IDEs typically invoke the linker for you after compiling your code.

d

Which of the following statements is false? a. Object-oriented programming is today's key programming methodology. b. C++ is one of today's most popular software development languages. c. Software commands computer hardware to perform tasks. d. In use today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices.

d

Which statement is false? a. Classes are reusable software components. b. A class is to an object as a blueprint is to a house. c. Performing a task in a program requires a method. d. A class is an instance of its object.

d

Which statement would be used to declare a 10-element integer array c? a. array c = int[10]; b. c = int[10]; c. int array c[10]; d. int c[10];

d

Which statement would be used to declare a 10-element integer array c? a. array c<12>; b. array c<int, 12>; c. array<12> c; d. array<int, 12> c;

d

sizeof: a. Is a binary operator. b. Returns the total number of elements in an array. c. Usually returns a double. d. Returns the total number of bytes in a variable.

d

Declaring data members with access specifier private is known as

data hiding

Data items processed by computers form a __________ that becomes larger and more complex in structure as we progress from bits to characters to fields, and so on.

data hierarchy

declared inside a class definition but outside the bodies of the class's member-function definitions

data members

The benefits of data integrity are not automatic simply because

data members are made private

Attributes are specified by the class's

data members.

If a class does not explicitly include constructors, the compiler provides a ______ with no parameters

default constructor

it's more precise to call a declaration that also reserves memory a

definition

Pascal

designed for teaching structured programming and was popular in college courses for several decades

When a value is placed in a memory location, the value overwrites the previous value in that location; thus, placing a new value into a memory location is said to be

destructive

Fortran

developed by IBM Corporations to be used for scientific and engineering applications that require complex mathematical computations

COBOL

developed by computer manufacturers, the U.S. government and industrial computer users based on a language developed by Grace Hopper

Basic

developed in 1960s in Dartmouth college to familiarize novices with programming techniques

Prompt

directs the user to take a specific action

Experience has shown that the best way to develop and maintain a large program is to construct it from small, simple pieces, or components. This technique is called

divide and conquer

The if...else statement is called a ___ because it selects between two different actions

double-selection statement

To help you prepare for the larger programs you'll encounter later in this book and in industry, we often use a separate source-code file containing function main to test our classes (this is called a ______).

driver program

C++ programs typically go through six phases:

edit, preprocess, compile, link, load and execute

White space

empty spaces in a design

Classes _______attributes and member functions into objects—an object's attributes and member functions are intimately related.

encapsulate (i.e., wrap)

An ____, introduced by the keyword enum and followed by a type name, is a set of integer constants represented by identifiers.

enumeration

Logic errors

errors that cause programs to execute incorrectly.

A linker links the object code with the code for the missing functions to produce an

executable program

the computer, under the control of its CPU, _____ the program one instruction at a time.

executes

A new class of objects can be created quickly and conveniently by ______—the new class absorbs the characteristics of an existing class, possibly customizing them and adding unique characteristics of its own.

inheritance

#include <iostream> notifies the preprocessor to include in the program the contents of the

input/output stream header file <iostream>.

An object is then referred to as an ______ of its class.

instance

Provide tools that support the software-development process, including editors for writing and editing programs and debuggers for locating logic errors

integrated development environments (IDEs)

The ____ describes what services a class's clients can use and how to request those services, but not how the class carries out the services

interface of a class

Memory unit/memory/primary memory

internal data storage in a computer

Declarations

introduce identifiers into programs.

Refactoring

involves reworking programs o make them clearer and easier to maintain while preserving their correctness and functionality

The software that contains the core components of the operating system is called the

kernel

Java

key goal is to be able to write programs that will run on a great variety of computer systems and computer-control devices

The UML is ____—it's used with many different programming languages

language independent

The UML represents data members as attributes by

listing the attribute name, followed by a colon and the attribute type

Variables declared in a function definition's body are known as ____ and can be used only from the line of their declaration in the function to the closing right brace (}) of the block in which they're declared

local variables

Variable names such as number1, number2 and sum actually correspond to _____ in the computer's memory.

locations

In some cases, writing != as =! will not be a syntax error, but almost certainly will be a

logic error

Placing a semicolon after the condition in an if statement leads to a

logic error

forgetting a break statement when one is needed in a switch statement is a

logic error

Confusing the equality operator == with the assignment operator = results in

logic errors

Omitting the braces that delimit a block can lead to

logic errors

Regardless of differences in physical appearance, computers can be envisioned as divided into various

logical units or sections

Variable names are said to be

lvalues

Any computer can directly understand only its own ______, defined by its hardware architecture.

machine language (also called machine code)

Performing a task in a program requires a

member function

Each message is implemented as a _______ that tells a member function of the object to perform its task.

member function call

The promotion rules apply to expressions containing values of two or more data types also referred to as

mixed-type expressions

C

most of code for general-purpose operating systems is written in C or C++

Linux

most popular open-source operating system; Popular in servers, personal computers and embedded systems

The switch selection statement is called a ___ because it selects among many different actions

multiple-selection statement

Set functions are also sometimes called

mutators

For fundamental-type variables, list-initialization syntax also prevents so-called ____ that could result in data loss.

narrowing conversions

When a value is read out of a memory location, the process is

nondestructive

a set of random numbers that can't be predicted

nondeterministic random numbers

If this process involves analyzing and designing your system from an object-oriented point of view, it's called an

object-oriented analysis and design (OOAD) process.

Objective-C

object-oriented language based on C

Using an incorrect relational operator or using an incorrect final value of a loop counter in the ocndition of a while or for statement can cause

off-by-one errors

C#

one of Microsoft's three object-oriented primary programming languages

Perl

one of the most widely used object-oriented scripting languages for web programming

Ruby on rails

open source, object-oriented programming language with a simple syntax that's similar to Perl and Python

Additional information that a function needs to perform its task is known as a

parameter

To specify that a function requires data to perform its task, you place additional information in the function's _____, which is located in the parentheses following the function name.

parameter list

Two ways to pass arguments to functions in many programming languages are

pass-by-value and pass-by-reference

A statement instructs the computer to

perform an action.

The C++ preprocessor obeys commands called ______, which indicate that certain manipulations are to be performed on the program before compilation.

preprocessing directives

A ____ program executes automatically before the compiler's translation phase begins

preprocessor

Automatic storage is an example of the

principle of least privilege

Computer programs guide the computer through ordered actions specified by people called computer

programmers

Function rand actually generates

pseudorandom numbers

A class's public interface consists of the class's public member functions (also known as the class's ___).

public services

a function that calls itself, either directly, or indirectly (through another function)

recursive function

As in algebra, it's acceptable to place unnecessary parentheses in an expression to make the expression clearer.These are called

redundant parentheses

Beta

released to a larger number of developers later in the development process after most major bugs have been fixed and new features are nearly complete

When you define a function, you must specify a ____ to indicate the type of the value returned by the function when it completes its task.

return type

Constants are said to be

rvalues

Agile software development

s set of methodologies that try to get software implemented faster and using fewer resources than previous methodologies

The portion of the program where an identifier can be used is known as its

scope

This restricted use of the control variable name is known as the variable's

scope

Each member-function name is preceded by the class name and ::, which is known as the

scope resolution operator

Function srand takes an unsigned integer argument and ____ the rand function to produce a different sequence of random numbers for each execution.

seeds

statement terminator

semicolon (;)

EOF stands for "end-of-file". Commonly used as a

sentinel value

statements in a program execute one after the other in the order in which they're written

sequential execution

This performance feature for the evaluation of logical AND and logical OR expressions is called

short-circuit evaluation

Visual Basic

simplified the development of Microsoft windows applications

A block can be placed anywhere in a program that a

single statement can be placed

A comment beginning with // is called a _____ because it terminates at the end of the current line.

single-line comment

The if selection statement is a ___ because it selects or ignores a single action

single-selection statement

The programs that run on a computer are referred to as

software

Continuous beta

software that's developed using this approach generally does not have version numbers

.cpp file, also known as a

source-code file

URL (Uniform Resource Locator)

specifies the address (i.e., location) of the web page displayed in the browser window.

If more function calls occur than can have their activation records stored on the function call stack, an a fatal error known as ___ occurs

stack overflow

When a cout statement executes, it sends a stream of characters to the ____—which is normally "connected" to the screen.

standard output stream object—std::cout

Stream manipulators fixed and setprecision remain in effect until they're changed—such settings are called

sticky settings

Arithmetic expressions in C++ must be entered into the computer in

straight-line form

std::endl is a so-called

stream manipulator

Together, the quotation marks and the characters between them are called a

string, a character string or a string literal.

Forgetting the semicolon at the end of a class definition is a

syntax error

The keystroke combinations for entering end-of-file are

system dependent

(UML)The solid circle at the top of the diagram represents

the activity's initial- state—the beginning of the workflow before the program performs the modeled activities.

Alpha

the earliest release of a software product that's still under active development

Secondary storage unit

the long-term, high-capacity "warehousing" section

The syntax of a programming language specified

the rules for creating proper programs in that language

All programs could be written in terms of only three control structures

the sequence structure the selection structure and the repetition structure

A computer's character set is

the set of all the characters used to write programs and represent data items

Bit

the smallest unit of data in a computer; binary digit 1s and 0s


Kaugnay na mga set ng pag-aaral

PassPoint Pharmacology Exam Prep

View Set

Chapter 5 - Molecules and Compounds

View Set

Intro. to Environmental Science - Exam 1

View Set

Marketing Chapter 12: The Promotion Mix

View Set