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
Computer Science
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
Q:
A(n) unsafe macro is one that ________.
a) evaluates its argument(s) exactly once
b) evaluates its argument(s) more than once
c) does not evaluate its argument(s)
d) None of the above.
Q:
. Which statement is false?
a) assert is a useful debugging tool for testing if a variable has a correct value
b) If NDEBUG is defined, only the next assertion is ignored.
c) The assert macro is defined in the assert.h header file.
d) One problem with using assert is that if the assertion is false, program execution is terminated; in some situations it is more appropriate to allow the program to continue executing after the program has dealt with the problem.
Q:
Which statement about the following assertion is true?
assert(count <= 7);
a) It evaluates its argument at preprocessor time.
b) It evaluates its argument at compile time.
c) It evaluates its argument at execution time.
d) It always calls function abort.
Q:
Which symbolic constant must be defined to ignore all assert statements?
(a) DEBUG
(b) NDEBUG
(c) NOASSERT
(d) UNASSERT
Q:
Which statement about predefined symbolic constants is false?
a) The predefined symbolic constants and the defined identifier cannot be used in #define or #undef directives.
b) __DATE__ is replaced by the date the source file is compiled.
c) __LINE__is used to specify the range of line numbers in the source file.
d) The identifiers for each of the predefined symbolic constants begin and end with two underscores.
Q:
Which of the following is not a predefined symbolic constant?
(a) __ERROR__
(b) __FILE__
(c) __TIME__
(d) __LINE__
Q:
The preprocessor directive
#line 200
a) numbers the first 200 lines of a source-code program from 1 to 200.
b) numbers the first 200 lines of a source-code program from 0 to 199.
c) starts line numbering from 200 beginning with the next source-code line
d) numbers the next line 200 and has no effect on other lines.
Q:
The statement #line 250
(a) causes the compiler to ignore everything after line 250.
(b) causes the compiler to renumber the lines from 250 beginning with the next source code line.
(c) causes the compiler to renumber the lines from 250 beginning with this statement line.
(d) causes line number 250 to be replaced by the text following the statement.
Q:
Operator ##
a) concatenates two tokens in a macro definition.
b) is a relational operator.
c) is the conditional-compilation operator.
d) is the symbolic-constant operator.
Q:
Given the preprocessor directive
#define HAPPY(x) printf ("Happy, " #x "
");
How would you invoke this macro to generate a statement that would print
Happy BIRTHDAY (followed by a newline)
at execution time?
a) Happy(Birthday)
b) Happy(BIRTHDAY)
c) HAPPY(Birthday)
d) HAPPY(BIRTHDAY)
Q:
The # preprocessor operator causes a replacement text token to be converted to
a) an integer
b) a string
c) a string surrounded by quotes
d) an integer surrounded by quotes
Q:
The # operator causes __________ to be converted to a __________.
(a) any preprocessor argument, user-defined type.
(b) a text token, string surrounded by quotes.
(c) a string, concatenated string.
(d) any float or int, string.
Q:
To customize preprocessing to the unique needs of a particular installation, you would most likely use the __________ directive.
a) #unique
b) #pragmatic
c) #pragma
d) #customize
Q:
A pragma not recognized by the implementation
a) causes the compilation to terminate.
b) prints an error message and causes the compilation to terminate.
c) prints an error message and allows the complation to continue.
d) is ignored.
Q:
The preprocessor directive
#pragmatokens
a) prints only the tokens specified in the message.
b) prints the word pragma followed by the tokens specified in the message.
c) causes an implementation-defined action.
d) prints an implementation-defined message including the tokens specified in the directive.
Q:
The preprocessor directive
#error 7 " Out of range error "
contains __________ tokens.
a) 8
b) 7
c) 9
d) 6
Q:
The #error directive
#errortokens
a) prints only the tokens specified in the message.
b) prints the word error followed by the tokens specified in the message.
c) prints only an implementation-defined message.
d) prints an implementation-defined message including the tokens specified in the directive.
Q:
Which line has the most tokens?
(a) I like C.
(b) I like C++ better.
(c) I like C + +.
(d) I prefer Java.
Q:
The __________ directive prints out a message.
(a) #error
(b) #pragma
(c) all of the above
(d) none of the above.
Q:
Which statement about conditional compilation is false?
a) Conditional compilation is commonly used as a debugging aid.
b) For debugging purposes, printf statements can be enclosed in conditional preprocessor directives so that the statements are compiled only while the debugging process is not completed.
c) A correct example of using a conditionally compiled printf statement only while a program is being debugged is
#ifdef DEBUG
printf("Variable x = %d
", x) ;
#endif
d) A single, conditionally compiled printf statement may be inserted in a program anywhere the C compiler expects a single statement.
Q:
Which statement about "commenting out" code is false?
a) During program development, programmers often find it helpful to "comment out" portions of code to prevent it from being compiled.
b) Code may not always be "commented out" correctly simply by enclosing that code in the C comment delimiters /* and */.
c) The following preprocessor code effectively comments out code
#if 0
code prevented from compiling
#endif
d) The following preprocessor code effectively comments out code
#if 1
code prevented from compiling
#endif
Q:
A shorthand for #if !defined is
a) #ifndef
b) #ifnotdef
c) #ifnotdefined
d) #ifndf
Q:
Every #if construct
a) must end with #end.
b) always affects code throughout the entire body of the program.
c) is used for debugging.
d) must end with #endif.
Q:
What does the following preprocessor code do?
#if !defined(NULL)
#define NULL 0
#endif
a) The code is incorrect, so it generates an error at preprocessor time.
b) The code ensures that NULL is always 0.
c) The code defines NULL to be 0 only if NULL is undefined.
d) The code ensures that NULL is defined throughout the entire program file.