Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Programming Language
Q:
Q1: 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,
Q:
Q2: 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.
Q:
Q1: 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.
Q:
Q3[C++11]: 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.
Q:
Q3[C++11]: 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.
Q:
Q2: 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.
Q:
Q1: 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).
Q:
Q2: 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.
Q:
Q1: 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.
Q:
Q2: 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. ->
Q:
Q1: 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.
Q:
Q6: 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
Q:
Q5: 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.
Q:
Q4: 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.
Q:
Q3: 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.
Q:
Q2: Which of the following preprocessor directives does not constitute part of the preprocessor wrapper?
a. #define
b. #endif
c. #ifndef
d. #include
Q:
Q1: 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.
Q:
Q2: 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".
Q:
Q1: To execute multiple statements when an if statement's condition is true, enclose those statements in a pair of:
a. Parentheses, ( ).
b. Square Brackets, [ ].
c. Braces, { }.
d. Angle brackets, < >.
Q:
Q3: 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.
Q:
Q2: When compiling a class's source code file (which does not contain a main function), the information in the class's header file is used for all of the following, except:
a. Ensuring that the header of each member function matches its prototype.
b. Ensuring that each member function knows about the class's data members and other member functions.
c. Determining the correct amount of memory to allocate for each object of the class.
d. All of the above are uses that the compiler has for the header file information.
Q:
Q1: In the source-code file containing a class's member function definitions, each member function definition must be tied to the class definition by preceding the member function name with the class name and ::, which is known as the:
a. Member definition linker.
b. Class implementation connector.
c. Source code resolver.
d. Scope resolution operator.
Q:
Q2: 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"
Q:
Q1: A header file is typically given the filename extension:
a. .h
b. .hdr
c. .header
d. .cpp
Q:
Q4 [C++11]: Which of the following is true?
a. The only way to define a constructor in a class is to explicitly define one.
b. If you define any constructors with arguments, the compiler will also define a default constructor.
c. If you define any constructors with arguments, the compiler will not define a default constructor.
d. You cannot explicitly create constructors.
Q:
Q3: The compiler will implicitly create a default constructor if:
a. The class does not contain any data members.
b. The programmer specifically requests that the compiler do so.
c. The class does not define any constructors.
d. The class already defines a default constructor.
Q:
Q2: A constructor can specify the return type:
a. int.
b. string.
c. void.
d. A constructor cannot specify a return type.
Q:
Q1: A default constructor has how many parameters?
a. 0.
b. 1.
c. 2.
d. Variable number.
Q:
Q3: What type of member functions allow a client of a class to assign values to private data members?
a. Client member functions.
b. Get member functions.
c. Set member functions.
d. None of the above.
Q:
Q2: What is the default initial value of a String?
a. ""
b. "default"
c. default
d. None of the above.
Q:
Q1: Attributes of a class are also known as:
a. Constructors.
b. Local variables.
c. Data members.
d. Classes.
Q:
Q3: Two adjacent parameters are separated by what symbol?
a. Dot.
b. Comma.
c. Parentheses.
d. Braces.
Q:
Q2: Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types Hello World! then presses Enter?
a. "H"
b. "Hello"
c. "Hello World"
d. "Hello World!"
Q:
Q1: What is the name of the values the method call passes to the method for the parameters?
a. Arguments.
b. References.
c. Objects.
d. Values.
Q:
Q3: 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.
Q:
Q2: Calling a member function of an object requires which item?
a. The dot operator.
b. Open and close braces.
c. The class name.
d. None of the above.
Q:
Q1: C++ functions other than main are executed:
a. Before main executes.
b. After main completes execution.
c. When they are explicitly called by another function.
d. Never.
Q:
Q2: Which of the following is not true of object-oriented design?
a. OOD takes advantage of inheritance relationships.
b.OOD encapsulates attributes and operations into objects.
c.OOD focuses on actions (verbs).
d.Each class can be used to create multiple objects.
Q:
Q1: The other classes or functions that use a certain class are referred to as its:
a. Clients.
b.Data members.
c.Member functions.
d.Methods.
Q:
Q3: Given the following function template
template < class T >
T maximum( T value1, T value2 )
{
if ( value1 > value2 )
return value1;
else
return value2;
}
what would be returned by the following two function calls?
maximum( 2, 5 );
maximum( 2.3, 5.2 );
a. 5 and a type-mismatch error.
b. 5 and 5.2.
c. 2 and 2.3.
d. Two error messages.
Q:
Q2: Which of the following is true of function templates?
a. All function templates begin with the keyword class.
b. Every formal type parameter is preceded by either keyword typename or template.
c. Formal type parameters act as placeholders for built-in types or user-defined types and are used to specify the types of arguments to the function, to specify the return type of the function, and to declare variables within the body of the function definition.
d. A programmer must define a separate function template for each template function specialization to be used in the program.
Q:
Q1: If a function's program logic and operations are identical for each data type it could receive as argument(s) then a __________ should be used.
a. Overloaded function.
b. Recursive function.
c. Macro.
d. Function template.
Q:
Q3: Type-safe linkage is ensured by:
a. Name mangling.
b. Calling the correct function.
c. The agreement of the arguments and parameters.
d. Specifying return types.
Q:
Q2: 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.
Q:
Q1: 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.
Q:
Q1: 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.
Q:
Q2: If the function int volume( int x = 1, int y = 1, int z = 1 ); is called by the expression volume( 3 ), how many default arguments are used?
a. None.
b. One.
c. Two.
d. Three.
Q:
Q1: 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.
Q:
Q2: Which of the following is false about the following function prototype?
void functionA( void );
a. It does not receive any arguments.
b. It could have been written void functionA( );.
c. It does not return a value.
d. It could have been written functionA( void );.
Q:
Q1: Which of the following is correct keyword to explicitly indicate that a function does not receive any parameters?
a.empty
b.void
c. epl
d. none
Q:
Q3: Call-by-reference can achieve the security of call-by-value when:
a. The value being passed is small.
b. A large argument is passed in order to improve performance.
c. A pointer to the argument is used.
d. The const qualifier is used.
Q:
Q2: A reference parameter:
a. Is an alias for its corresponding argument.
b. Is declared by following the parameter's type in the function prototype by an ampersand (&).
c. Cannot be modified.
d. Both (a) and (b).
Q:
Q1: When an argument is passed-by-value, changes in the calling function __________ affect the original variable's value; when an argument is passed call-by-reference, changes __________ affect the original variable's value.
a. Do not, do.
b. Do not, do not.
c. Do, do.
d. Do, do not.
Q:
Q1: 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.
Q:
Q2: Which of the following C++ Standard Library header files does not contain a C++ Standard Library container class?
a. <vector>.
b. <list>.
c. <stack>.
d. <string>.
Q:
Q1: Each standard library has a corresponding:
a. Function.
b. Variable type.
c. Header file.
d. Cd-rom.
Q:
Q1: Which of the following statements about the C++ Standard Library is false:
a.The C++ Standard Library consists of classes and functions that perform tasks.
b.The C++ Standard Library is an important part of the C++ "world."
c.An advantage of using classes and functions from the C++ Standard Library is saving the effort of designing, developing and testing new classes.
d.The C++ Standard Library functions and classes are not included in every C++ implementation.
Q:
Q3: Which of the following is a variable declaration statement?
a.int total;
b.#include <iostream>
c.int main()
d.// first string entered by user
Q:
Q2: A(n) ________ enables a program to read data from the user.
a.std::cout.
b.std::cin.
c.return statement.
d.main declaration.
Q:
Q1: End-of-line comments that should be ignored by the compiler are denoted using:
a.Two forward slashes ( // ).
b.Three forward slashes ( /// ).
c.A slash and a star ( /* ).
d.A slash and two stars (/** ).
Q:
Q2: C++ is a:
a.Typeless language.
b.Hybrid object-oriented language.
c.Subset of the C Language.
d.Pure object-oriented language.
Q:
Q1: Today, virtually all new major operating systems are written in:
a.B or BCPL.
b.C or C++.
c.UNIX.
d.Smalltalk.
Q:
A label must
(a) be defined as a global constant prior to use
(b) appear in the same function as the goto statement that refers to it
(c) be of type int
(d) all of the above
Q:
The goto statement is which of the following?
(a) an unconditional branch
(b) an instance of unstructured programming
(c) used to change the program's flow of control
(d) all of the above
Q:
realloc is conventionally used to
(a) allocate memory for a single object
(b) allocate memory for an array of objects
(c) change the size of an object previously allocated
(d) change the contents of an object previously allocated
Q:
Which of the following will not generate a signal defined in the header signal.h?
(a) a call to exit
(b) dividing by zero
(c) a call to abort
(d) an invalid access to storage
Q:
SIGFPE signals
(a) an erroneous arithmetic operation
(b) the abnormal termination of the program
(c) the detection of an illegal instruction
(d) an invalid access to storage
Q:
A floating-point constant that's not suffixed is of type
(a) double
(b) float
(c) unsigned float
(d) long double
Q:
The function atexit takes as an argument
(a) the line number of where the program should exit
(b) a function that is executed when the program is exited unsuccessfully
(c) a function to be called when the program ends successfully
(d) normally the symbolic constant EXIT_SUCCESS or EXIT_FAILURE
Q:
When exit is called with EXIT_FAILURE
(a) the program quits immediately without returning anything
(b) the program prints an error message and quits the current function
(c) the implementation-defined value for unsuccessful termination is returned
(d) the program breaks out of a loop
Q:
Which of the following restricts the scope of a global variable to the file it's defined in?
(a) extern
(b) static
(c) int
(d) local
Q:
Which of the following is not an error?
(a) having a function definition that spans two files
(b) using a global variable in a file it was not defined in without defining it with the extern modifier
(c) defining a function prototype without the extern keyword when the definition is in another file
(d) having global variables in different files with the same name
Q:
Global variables can be used to increase performance because
(a) global variables are accessed faster than local variables
(b) the overhead of passing data between functions is eliminated
(c) they are stored more compactly than local variables
(d) all of the above
Q:
extern
(a) is a keyword to indicate that a variable is defined in a different file
(b) is used to access command-line arguments
(c) can be used as a control structure
(d) is a data type
Q:
Which of the following operating systems require special settings for processing command-line arguments?
(a) Macintosh
(b) DOS
(c) UNIX
(d) all of the above
Q:
How many arguments can be passed to main from the command line?
(a) 1
(b) 2
(c) 3
(d) as many as you want
Q:
What macro expands to an expression of the value and type of the next argument in a variable-length argument list?
(a) va_end
(b) va_start
(c) va_list
(d) va_arg
Q:
Which of the following function prototypes is correct?
(a) double average(int, ...)
(b) double average(..., int);
(c) double average(int, ...);
(d) double average(int, ... , int);
Q:
Which of the following symbols is not used in UNIX for redirecting input or output?
(a) >
(b) |
(c) $
(d) >>
Q:
A pipe (|) causes
(a) the output of the first program to be redirected to the input of the second
(b) the output of the second program to be redirected to the input of the first
(c) the input of the first program to be redirected to the input of the second
(d) the input of the second program to be redirected to the input of the first