1. You can use C++ as a procedural, as well as an object-oriented, language
A. True
B. False
Answer & Explanation
Answer: Option A
2. A default catch block catches
A. all thrown objects
B. no thrown objects
C. any thrown object that has not been caught by an earlier catch block
D. all thrown objects that have been caught by an earlier catch block
Answer & Explanation
Answer: Option C
3. Adding a derived class to a base class requires fundamental changes to the base class
A. True
B. False
Answer & Explanation
Answer: Option B
4. Format flags may be combined using
A. the bitwise OR operator (|)
B. the logical OR operator (||)
C. the bitwise AND operator (&)
D. the logical AND operator (&&)
Answer & Explanation
Answer: Option A
5. The use of the break statement in a switch statement is
A. optional
B. compulsory
C. not allowed. It gives an error message
D. to check an error
E. None of the above
Answer & Explanation
Answer: Option A
6. To expose a data member to the program, you must declare the data member in the _____ section of the class
A. common
B. exposed
C. public
D. unrestricted
E. user Answer & Explanation
Answer: Option C
7. Evaluate the following expression: 3 >6&&7>4
A. True
B. False
Answer & Explanation
Answer: Option B
8. Which of the following are valid characters for a numeric literal constant?
A. a comma
B. a dollar sign ($)
C. a percent sign (%)
D. a space
E. None of the above
Answer & Explanation
Answer: Option E
9. A function that changes the state of the cout object is called a(n) _____
A. member
B. adjuster
C. manipulator
D. operator
Answer & Explanation
Answer: Option C
10. A C++ program contains a function with the header int function(double d, char c). Which of the following function headers could be used within the same program?
A. char function(double d, char c)
B. int function(int d, char c)
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option B
11. When the compiler cannot differentiate between two overloaded constructors, they are called
A. overloaded
B. Destructed
C. ambiguous
D. Dubious
Answer & Explanation
Answer: Option C
12. Some Streams work with input, and some with output
A. True
B. False
Answer & Explanation
Answer: Option A
13. If you design a class that needs special initialization tasks, you will want to design a(n) _____
A. housekeeping routine
B. initializer
C. constructor
D. compiler
Answer & Explanation
Answer: Option C
14. Which type of statement does not occur in computer programs?
A. sequence
B. loop
C. denial
D. selection
Answer & Explanation
Answer: Option C
15. The newline character is always included between
A. pair of parentheses
B. pair of curly braces
C. control string
D. &
E. None of the above
Answer & Explanation
Answer: Option C
16. To be called object-oriented, a programming language must allow
A. functions that return only a single value
B. #include files
C. inheritance
D. All of the above
Answer & Explanation
Answer: Option C
17. A function that returns no values to the program that calls it is _____
A. not allowed in C++
B. type void
C. type empty
D. type barren
Answer & Explanation
Answer: Option B
18. The keyword used to define a structure is _____
A. stru
B. stt
C. struct
D. structure
Answer & Explanation
Answer: Option C
19. If container classes are carefully constructed, then these tools are available to work with structures that are not ______
A. valid without container classes
B. programmer-defined
C. type-specific
D. public
Answer & Explanation
Answer: Option C
20. Header files often have the file extension _____
A. .H
B. .HE
C. .HEA
D. .HEAD
Answer & Explanation
Answer: Option A
21. The #ifndef directive tests to see whether ________
A. a class has been defined
B. a variable has been given a value
C. a class has no variable definitions
D. any objects of the class have been instantiated
Answer & Explanation
Answer: Option A
22. Which of the following statements is false?
A. A function is a block of code that performs a specific task
B.
Functions allow programmers to break large and complex problems into small and manageable tasks
C. Functions allow programmers to use existing code to perform common tasks
D. Functions can be called, or invoked, only once in a program
E. Programmer-defined functions can be either value-returning or void
Answer & Explanation
Answer: Option D
23. The generic type in a template function
A. must be T
B. can be T
C. cannot be T for functions you create, but may be for C++'s built-in functions
D. cannot be T
Answer & Explanation
Answer: Option B
24. When a child class function is called, the compiler looks first for a matching function name in the _____
A. class of the object using the function name
B. immediate ancestor class
C. base class
D. descendant class
Answer & Explanation
Answer: Option A
25. A function that is called automatically each time an object is destroyed is a
A. constructor
B. destructor
C. destroyer
D. terminator
Answer & Explanation
Answer: Option B
26. If you create an instantiation of a class template with an int, and then create a second instantiation with a double, then
A. you must precede each function call with the word int or double
B.
once a function is used as one type, it becomes unavailable for use with the other type
C. there is no difference in the procedure to call a member function
D. you cannot perform this operation in C++
Answer & Explanation
Answer: Option A
27. The step-by-step instructions that solve a problem are called _____
A. an algorithm
B. a list
C. a plan
D. a sequential structure
Answer & Explanation
Answer: Option A
28. The type to be used in an instantiation of a class template follows ________
A. the generic class name
B. the keyword template
C. the keyword class
D. the template definition
Answer & Explanation
Answer: Option A
29. Which of the following statements allows the user to enter data at the keyboard?
A. cin << currentPay;
B. cin >> currentPay;
C. cout << currentPay;
D. cout >> currentPay;
E. None of the above
Answer & Explanation
Answer: Option B
30. When you pass a variable _____, C++ passes only the contents of the variable to the receiving function
A. by reference
B. by value
C. Globally
D. Locally
Answer & Explanation
Answer: Option B
31. The best form of coupling is _____
A. complete
B. Tight
C. loose
D. Free
Answer & Explanation
Answer: Option C
32. Paying attention to the important properties while ignoring inessential details is known as________
A. selectiveness
B. Polymorphism
C. abstraction
D. Summarizing
Answer & Explanation
Answer: Option C
33. What does C++ append to the end of a string literal constant?
A. a space
B. a number sign (#)
C. an asterisk (*)
D. a null character
Answer & Explanation
Answer: Option D
34. An array name is a _____
A. Subscript
B. formal parameter
C. memory address
D. Prototype
Answer & Explanation
Answer: Option C
35. To enter a comment in a C++ program, you begin the comment with _____
A. **
B. &&
C. \\
D. @
E. // Answer & Explanation
Answer: Option E
36. Which of the following is(are) invalid string constant(s)?
A. '7.15 pm'
B. "i like e"
C. "7.3el2"
D. "1234el2"
E. None of the above
Answer & Explanation
Answer: Option A
37. You define a structure type globally because _____
A.
you save many lines of code by not rewriting an identical structure definition in each function that uses it
B. you will never change its definition
C. it is required in C++
D. All of the above
Answer & Explanation
Answer: Option A
38. Overloaded functions are required to
A. have the same return type
B. have the same number of parameters
C. perform the same basic functions
D. None of the above
Answer & Explanation
Answer: Option D
39. Redirection redirects
A. a stream from a file to the screen
B. a file from a device to a stream
C. a device from the screen to a file
D. the screen from a device to a stream
Answer & Explanation
Answer: Option A
40. You mark the beginning of a function's block of code with the _____
A. /
B. *
C. {
D. }
E. either (c) or (d) can be used
Answer & Explanation
Answer: Option C
41. Sending a copy of data to a program module is called _______
A. passing a value
B. making a reference
C. Recursion
D. setting a condition
Answer & Explanation
Answer: Option A
42. Of the three ways to pass arguments to functions, only passing by _____ and passing by _____ allow the function to modify the argument in the calling program
A. reference, pointer
B. array, location
C. array, pointer
D. None of the above
Answer & Explanation
Answer: Option A
43. To use either an input or output file, the program must include the _____ header file
A. filestream.h
B. fstream.h
C. instream.h
D. inoutstream.h
E. iostream.h Answer & Explanation
Answer: Option B
44. A widget is to the blueprint for a widget as an object is to
A. a member function
B. a class
C. an operator
D. a data item
Answer & Explanation
Answer: Option B
45. C++ allows you to define the same functions more than once in the same program _____
A. if the definitions are identical
B. if the definitions are included in two separate #include files
C.
if the definitions are located in a single #include file that is included more than once
D.
C++ does not allow you to define the same functions more than once in the same program
Answer & Explanation
Answer: Option D
46. Which of the following assigns the number 5 to the area variable?
A. area 1 = 5
B. area = 5
C. area == 5
D. area --> 5
E. area < > 5
Answer & Explanation
Answer: Option B
47. A base class may also be called a
A. child class
B. Subclass
C. derived class
D. parent class
Answer & Explanation
Answer: Option D
48. The _____ mode tells C++ to open a file for input
A. add::ios
B. in::file
C. ios::app
D. ios::in
E. ios::out Answer & Explanation
Answer: Option D
49. Using the wardrobe structure within the ShopList structure is an example of a good programming principle, known as _____
A. reusability
B. Polymorphism
C. redundancy
D. Recursion
Answer & Explanation
Answer: Option A
1. When you omit parameters from a function call, values can be provided by
A. formal parameters
B. reference parameters
C. overloaded parameters
D. default parameters
Answer & Explanation
Answer: Option D
2. The first element in a string is
A. the name of the string
B. the first character in the string
C. the length of the string
D. the name of the array holding the string
Answer & Explanation
Answer: Option B
3. Variables declared outside a block are called _____
A. global
B. Universal
C. stellar
D. External
Answer & Explanation
Answer: Option A
4. The compiler converts your C++ instructions into _____
A. edited code
B. object code
C. source code
D. translated code
Answer & Explanation
Answer: Option B
5. A fundamental type such as int or double is a _____
A. programmer-defined type
B. complex type
C. nonscalar type
D. scalar type
Answer & Explanation
Answer: Option D
6. The return type you code for all constructors is _____
A. Void
B. the class type
C. the same type as the first data member defined in the class
D. no type
Answer & Explanation
Answer: Option D
7. When an object-oriented program detects an error within a function, the function _________
A. throws an exception
B. throws a fit
C. catches a message
D. catches an exception
Answer & Explanation
Answer: Option A
8. Using a statement at the wrong time or with an inappropriate object creates a
A. logical error
B. syntax error
C. compiler error
D. language error
Answer & Explanation
Answer: Option A
9. When you create a derived class and instantiate an object _____
A. the parent class object must be constructed first
B. the child class object must be constructed first
C. the parent class object must not be constructed
D. the child class object must not be constructed
Answer & Explanation
Answer: Option A
10. Evaluate the following expression: 4 >6 || 10 < 2 * 6
A. True
B. False
Answer & Explanation
Answer: Option A
11. A constructor always has
A. communicational cohesion
B. temporal cohesion
C. logical cohesion
D. no cohesion
Answer & Explanation
Answer: Option B
12. A normal C++ operator that acts in special ways on newly defined data types is said to be
A. glorified
B. Encapsulated
C. classified
D. Overloaded
Answer & Explanation
Answer: Option D
13. A function in a derived class that has the same name as a function in the parent class
A. will override the base class function
B. will cause an error message to display
C. will be overridden by the base class function
D. will execute immediately often the base class function executes
Answer & Explanation
Answer: Option A
14. In which statements, does a 'continue' statements cause the control to go directly to the test condition and then continue the looping process?
A. 'for' and 'while'
B. 'while' and 'if-else'
C. 'do-while' and 'if-else'
D. 'while' and 'do-while'
E. None of the above
Answer & Explanation
Answer: Option D
15. Which of the following statements is false?
A.
You typically use a public member function to change the value in a private data member
B.
Because the constructor function does not return a value, you place the keyword void before the constructor's name
C.
The public member functions in a class can be accessed by any program that uses an object created from that class
D. An instance of a class is considered an object
Answer & Explanation
Answer: Option B
16. In a class specifier, data or functions designated private are accessible
A. to any function in the program
B. only if you know the password
C. to member functions of that class
D. only to public members of the class
Answer & Explanation
Answer: Option C
17. When a function includes a throw statement for errors, the call to the potentially offending function should be placed within a _____ block
A. throw
B. Try
C. catch
D. Scope
Answer & Explanation
Answer: Option B
18. The scope resolution operator is
A. a comma
B. a semicolon
C. a colon
D. two colons
Answer & Explanation
Answer: Option D
19. "C++" is a _____ constant
A. character literal
B. named literal
C. numeric literal
D. string literal
Answer & Explanation
Answer: Option D
20. In a C++ program, which of the following can be thrown?
A. scalar variables
B. programmer-defined objects
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option B
21. The items listed in the function header are called _____
A. actual arguments
B. formal parameters
C. passed parameters
D. sent arguments
Answer & Explanation
Answer: Option B
22. A translator that notes whether you have used a language correctly may be called a _____
A. theasurus
B. Compiler
C. coder
D. Decoder
Answer & Explanation
Answer: Option B
23. The feature in object-oriented programming that allows the same operation to be carried out differently, depending on the object, is_____
A. inheritance
B. Polymorphism
C. overfunctioning
D. Overriding
Answer & Explanation
Answer: Option B
24. When an argument is passed by reference,
A. a variable is created in the function to hold the argument's value
B. the function cannot access the argument's value
C.
a temporary variable is created in the calling program to hold the argument's value
D. the function accesses the argument's original value in the calling program
E. None of the above
Answer & Explanation
Answer: Option D
25. The process of extracting the relevant attributes of an object is known as
A. Polymorphism
B. Inheritance
C. Abstraction
D. data hiding
Answer & Explanation
Answer: Option C
26. Which of the following statements uses the computer's clock to initialize the random number generator?
A. srand(time);
B. srand(time(NULL));
C. time(srand);
D. time(srand(NULL));
Answer & Explanation
Answer: Option B
27. A static data member is given a value
A. within the class definition
B. outside the class definition
C. when the program is executed
D. Never
Answer & Explanation
Answer: Option B
28. You must provide a constructor for a derived class
A. Always
B. if the base class constructor required arguments
C. if the base class constructor does not required arguments
D. Never
Answer & Explanation
Answer: Option B
29. If you want to override constructor default values for an object you are instantiating, you must also override
A. all other parameters to that constructor
B. all parameters to the left of that value
C. all parameters to the right of that value
D. no other parameters to that constructor
Answer & Explanation
Answer: Option B
30. To use one of the C++ built-in mathematical functions, you must include the _____ header file in your program
A. calculation.h
B. compute.h
C. expression.h
D. math.h
E. mathematical.h
Answer & Explanation
Answer: Option D
31. Errors in a program are called
A. Accidents
B. Annoyances
C. Bugs
D. Mistakes
E. typing errors
Answer & Explanation
Answer: Option C
32. If you declare two objects as Customer firstCust, secondCust; which of the following must be true?
A.
Each object's nonstatic data members will be stored in the same memory location
B. Each object will be stored in the same memory location
C. Each object will have a unique memory address
D. You cannot declare two objects of the same class
Answer & Explanation
Answer: Option C
33. Which of the following is the inequality operator?
A. != B. =
C. == D. -->
E. <> Answer & Explanation
Answer: Option A
34. If a derived class uses the public access specifier, then _____
A. public base class members remain public in the derived class
B. protected base class members become public in the derived class
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option A
35. The operator that releases previously allocated memory is _____
A. release
B. Return
C. delete
D. Destroy
Answer & Explanation
Answer: Option C
36. When a language has the capability to produce new data types, it is said to be
A. reprehensible
B. Encapsulated
C. overloaded
D. Extensible
Answer & Explanation
Answer: Option D
37. A compound statement does not consist of
A. a single statement
B. other compound statements
C. expression statements
D. control statements
E. None of the above
Answer & Explanation
Answer: Option A
38. Which of the following statements will display the word "Hello" on the computer screen?
A. cin << "Hello";
B. cin >> "Hello";
C. cout << "Hello";
D. cout >> "Hello";
E. None of the above
Answer & Explanation
Answer: Option C
39. The preprocessor directive always starts with the symbol
A. %
B. &
C. #
D. ""
E. None of the above
Answer & Explanation
Answer: Option C
40. Which of the following statements is true?
A. Data coupling is tighter than pathological coupling
B. Common coupling is looser than data coupling
C. Data-structured coupling is looser than control coupling
D. Control coupling is looser than data coupling
Answer & Explanation
Answer: Option C
41. Evaluate the following expression: 7 >=3 + 4 || 6<4 && 2<5
A. True
B. False
Answer & Explanation
Answer: Option A
42. The base class for most stream classes is the _____ class
A. ios
B. Out
C. in
D. App
Answer & Explanation
Answer: Option A
43. Which of the following while clause will stop the loop when the value in the age variable is less than the number 0?
A. while age < 0
B. while (age < 0)
C. while age >= 0;
D. while (age >= 0);
E. while (age >= 0)
Answer & Explanation
Answer: Option E
44. The most efficient data type for a variable that stores the number 4.6e20 is the _____ data type
A. Character
B. Double
C. Float
D. Long Integer
E. Short Integer
Answer & Explanation
Answer: Option C
45. Which of the following is a C++ object?
A. cin
B. >>
C. iostream
D. read()
Answer & Explanation
Answer: Option A
46. Which of the following can be used to declare the main function?
A. void main
B. void Main()
C. void main()
D. Main
E. either (b) or (c) can be used
Answer & Explanation
Answer: Option C
47. You _____ write your own container classes
A. Must
B. May
C. should not
D. must not
Answer & Explanation
Answer: Option B
48. If an integer object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is
A. Int
B. Double
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option A
49. The highest level of cohesion is
A. functional cohesion
B. temporal cohesion
C. logical cohesion
D. sequential cohesion
Answer & Explanation
Answer: Option A
50. You separate a derived class name from its access specifier with
A. a colon
B. two colons
C. at least one space
D. a semicolon
Answer & Explanation
Answer: Option C
1. The last statement in a function is often a(n) _____
A. return
B. Goodbye
C. finish
D. Endfunction
Answer & Explanation
Answer: Option A
2. When the function int someFunction(char c) throw( ) is executed, _____
A. it can throw anything
B. it may throw an integer
C. it may throw a character
D. it may not throw anything
Answer & Explanation
Answer: Option D
3. The two statements that can be used to change the flow of control are
A. if and switch
B. if and while
C. switch and do-while
D. break and continue
E. None of the above
Answer & Explanation
Answer: Option A
1. You can use C++ as a procedural, as well as an object-oriented, language
A. True
B. False
Answer & Explanation
Answer: Option A
2. A default catch block catches
A. all thrown objects
B. no thrown objects
C. any thrown object that has not been caught by an earlier catch block
D. all thrown objects that have been caught by an earlier catch block
Answer & Explanation
Answer: Option C
3. Adding a derived class to a base class requires fundamental changes to the base class
A. True
B. False
Answer & Explanation
Answer: Option B
4. Format flags may be combined using
A. the bitwise OR operator (|)
B. the logical OR operator (||)
C. the bitwise AND operator (&)
D. the logical AND operator (&&)
Answer & Explanation
Answer: Option A
5. The use of the break statement in a switch statement is
A. optional
B. compulsory
C. not allowed. It gives an error message
D. to check an error
E. None of the above
Answer & Explanation
Answer: Option A
6. To expose a data member to the program, you must declare the data member in the _____ section of the class
A. common
B. exposed
C. public
D. unrestricted
E. user Answer & Explanation
Answer: Option C
7. Evaluate the following expression: 3 >6&&7>4
A. True
B. False
Answer & Explanation
Answer: Option B
8. Which of the following are valid characters for a numeric literal constant?
A. a comma
B. a dollar sign ($)
C. a percent sign (%)
D. a space
E. None of the above
Answer & Explanation
Answer: Option E
9. A function that changes the state of the cout object is called a(n) _____
A. member
B. adjuster
C. manipulator
D. operator
Answer & Explanation
Answer: Option C
10. A C++ program contains a function with the header int function(double d, char c). Which of the following function headers could be used within the same program?
A. char function(double d, char c)
B. int function(int d, char c)
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option B
11. When the compiler cannot differentiate between two overloaded constructors, they are called
A. overloaded
B. Destructed
C. ambiguous
D. Dubious
Answer & Explanation
Answer: Option C
12. Some Streams work with input, and some with output
A. True
B. False
Answer & Explanation
Answer: Option A
13. If you design a class that needs special initialization tasks, you will want to design a(n) _____
A. housekeeping routine
B. initializer
C. constructor
D. compiler
Answer & Explanation
Answer: Option C
14. Which type of statement does not occur in computer programs?
A. sequence
B. loop
C. denial
D. selection
Answer & Explanation
Answer: Option C
15. The newline character is always included between
A. pair of parentheses
B. pair of curly braces
C. control string
D. &
E. None of the above
Answer & Explanation
Answer: Option C
16. To be called object-oriented, a programming language must allow
A. functions that return only a single value
B. #include files
C. inheritance
D. All of the above
Answer & Explanation
Answer: Option C
17. A function that returns no values to the program that calls it is _____
A. not allowed in C++
B. type void
C. type empty
D. type barren
Answer & Explanation
Answer: Option B
18. The keyword used to define a structure is _____
A. stru
B. stt
C. struct
D. structure
Answer & Explanation
Answer: Option C
19. If container classes are carefully constructed, then these tools are available to work with structures that are not ______
A. valid without container classes
B. programmer-defined
C. type-specific
D. public
Answer & Explanation
Answer: Option C
20. Header files often have the file extension _____
A. .H
B. .HE
C. .HEA
D. .HEAD
Answer & Explanation
Answer: Option A
21. The #ifndef directive tests to see whether ________
A. a class has been defined
B. a variable has been given a value
C. a class has no variable definitions
D. any objects of the class have been instantiated
Answer & Explanation
Answer: Option A
22. Which of the following statements is false?
A. A function is a block of code that performs a specific task
B.
Functions allow programmers to break large and complex problems into small and manageable tasks
C. Functions allow programmers to use existing code to perform common tasks
D. Functions can be called, or invoked, only once in a program
E. Programmer-defined functions can be either value-returning or void
Answer & Explanation
Answer: Option D
23. The generic type in a template function
A. must be T
B. can be T
C. cannot be T for functions you create, but may be for C++'s built-in functions
D. cannot be T
Answer & Explanation
Answer: Option B
24. When a child class function is called, the compiler looks first for a matching function name in the _____
A. class of the object using the function name
B. immediate ancestor class
C. base class
D. descendant class
Answer & Explanation
Answer: Option A
25. A function that is called automatically each time an object is destroyed is a
A. constructor
B. destructor
C. destroyer
D. terminator
Answer & Explanation
Answer: Option B
26. If you create an instantiation of a class template with an int, and then create a second instantiation with a double, then
A. you must precede each function call with the word int or double
B.
once a function is used as one type, it becomes unavailable for use with the other type
C. there is no difference in the procedure to call a member function
D. you cannot perform this operation in C++
Answer & Explanation
Answer: Option A
27. The step-by-step instructions that solve a problem are called _____
A. an algorithm
B. a list
C. a plan
D. a sequential structure
Answer & Explanation
Answer: Option A
28. The type to be used in an instantiation of a class template follows ________
A. the generic class name
B. the keyword template
C. the keyword class
D. the template definition
Answer & Explanation
Answer: Option A
29. Which of the following statements allows the user to enter data at the keyboard?
A. cin << currentPay;
B. cin >> currentPay;
C. cout << currentPay;
D. cout >> currentPay;
E. None of the above
Answer & Explanation
Answer: Option B
30. When you pass a variable _____, C++ passes only the contents of the variable to the receiving function
A. by reference
B. by value
C. Globally
D. Locally
Answer & Explanation
Answer: Option B
31. The best form of coupling is _____
A. complete
B. Tight
C. loose
D. Free
Answer & Explanation
Answer: Option C
32. Paying attention to the important properties while ignoring inessential details is known as________
A. selectiveness
B. Polymorphism
C. abstraction
D. Summarizing
Answer & Explanation
Answer: Option C
33. What does C++ append to the end of a string literal constant?
A. a space
B. a number sign (#)
C. an asterisk (*)
D. a null character
Answer & Explanation
Answer: Option D
34. An array name is a _____
A. Subscript
B. formal parameter
C. memory address
D. Prototype
Answer & Explanation
Answer: Option C
35. To enter a comment in a C++ program, you begin the comment with _____
A. **
B. &&
C. \\
D. @
E. // Answer & Explanation
Answer: Option E
36. Which of the following is(are) invalid string constant(s)?
A. '7.15 pm'
B. "i like e"
C. "7.3el2"
D. "1234el2"
E. None of the above
Answer & Explanation
Answer: Option A
37. You define a structure type globally because _____
A.
you save many lines of code by not rewriting an identical structure definition in each function that uses it
B. you will never change its definition
C. it is required in C++
D. All of the above
Answer & Explanation
Answer: Option A
38. Overloaded functions are required to
A. have the same return type
B. have the same number of parameters
C. perform the same basic functions
D. None of the above
Answer & Explanation
Answer: Option D
39. Redirection redirects
A. a stream from a file to the screen
B. a file from a device to a stream
C. a device from the screen to a file
D. the screen from a device to a stream
Answer & Explanation
Answer: Option A
40. You mark the beginning of a function's block of code with the _____
A. /
B. *
C. {
D. }
E. either (c) or (d) can be used
Answer & Explanation
Answer: Option C
41. Sending a copy of data to a program module is called _______
A. passing a value
B. making a reference
C. Recursion
D. setting a condition
Answer & Explanation
Answer: Option A
42. Of the three ways to pass arguments to functions, only passing by _____ and passing by _____ allow the function to modify the argument in the calling program
A. reference, pointer
B. array, location
C. array, pointer
D. None of the above
Answer & Explanation
Answer: Option A
43. To use either an input or output file, the program must include the _____ header file
A. filestream.h
B. fstream.h
C. instream.h
D. inoutstream.h
E. iostream.h Answer & Explanation
Answer: Option B
44. A widget is to the blueprint for a widget as an object is to
A. a member function
B. a class
C. an operator
D. a data item
Answer & Explanation
Answer: Option B
45. C++ allows you to define the same functions more than once in the same program _____
A. if the definitions are identical
B. if the definitions are included in two separate #include files
C.
if the definitions are located in a single #include file that is included more than once
D.
C++ does not allow you to define the same functions more than once in the same program
Answer & Explanation
Answer: Option D
46. Which of the following assigns the number 5 to the area variable?
A. area 1 = 5
B. area = 5
C. area == 5
D. area --> 5
E. area < > 5
Answer & Explanation
Answer: Option B
47. A base class may also be called a
A. child class
B. Subclass
C. derived class
D. parent class
Answer & Explanation
Answer: Option D
48. The _____ mode tells C++ to open a file for input
A. add::ios
B. in::file
C. ios::app
D. ios::in
E. ios::out Answer & Explanation
Answer: Option D
49. Using the wardrobe structure within the ShopList structure is an example of a good programming principle, known as _____
A. reusability
B. Polymorphism
C. redundancy
D. Recursion
Answer & Explanation
Answer: Option A
1. When you omit parameters from a function call, values can be provided by
A. formal parameters
B. reference parameters
C. overloaded parameters
D. default parameters
Answer & Explanation
Answer: Option D
2. The first element in a string is
A. the name of the string
B. the first character in the string
C. the length of the string
D. the name of the array holding the string
Answer & Explanation
Answer: Option B
3. Variables declared outside a block are called _____
A. global
B. Universal
C. stellar
D. External
Answer & Explanation
Answer: Option A
4. The compiler converts your C++ instructions into _____
A. edited code
B. object code
C. source code
D. translated code
Answer & Explanation
Answer: Option B
5. A fundamental type such as int or double is a _____
A. programmer-defined type
B. complex type
C. nonscalar type
D. scalar type
Answer & Explanation
Answer: Option D
6. The return type you code for all constructors is _____
A. Void
B. the class type
C. the same type as the first data member defined in the class
D. no type
Answer & Explanation
Answer: Option D
7. When an object-oriented program detects an error within a function, the function _________
A. throws an exception
B. throws a fit
C. catches a message
D. catches an exception
Answer & Explanation
Answer: Option A
8. Using a statement at the wrong time or with an inappropriate object creates a
A. logical error
B. syntax error
C. compiler error
D. language error
Answer & Explanation
Answer: Option A
9. When you create a derived class and instantiate an object _____
A. the parent class object must be constructed first
B. the child class object must be constructed first
C. the parent class object must not be constructed
D. the child class object must not be constructed
Answer & Explanation
Answer: Option A
10. Evaluate the following expression: 4 >6 || 10 < 2 * 6
A. True
B. False
Answer & Explanation
Answer: Option A
11. A constructor always has
A. communicational cohesion
B. temporal cohesion
C. logical cohesion
D. no cohesion
Answer & Explanation
Answer: Option B
12. A normal C++ operator that acts in special ways on newly defined data types is said to be
A. glorified
B. Encapsulated
C. classified
D. Overloaded
Answer & Explanation
Answer: Option D
13. A function in a derived class that has the same name as a function in the parent class
A. will override the base class function
B. will cause an error message to display
C. will be overridden by the base class function
D. will execute immediately often the base class function executes
Answer & Explanation
Answer: Option A
14. In which statements, does a 'continue' statements cause the control to go directly to the test condition and then continue the looping process?
A. 'for' and 'while'
B. 'while' and 'if-else'
C. 'do-while' and 'if-else'
D. 'while' and 'do-while'
E. None of the above
Answer & Explanation
Answer: Option D
15. Which of the following statements is false?
A.
You typically use a public member function to change the value in a private data member
B.
Because the constructor function does not return a value, you place the keyword void before the constructor's name
C.
The public member functions in a class can be accessed by any program that uses an object created from that class
D. An instance of a class is considered an object
Answer & Explanation
Answer: Option B
16. In a class specifier, data or functions designated private are accessible
A. to any function in the program
B. only if you know the password
C. to member functions of that class
D. only to public members of the class
Answer & Explanation
Answer: Option C
17. When a function includes a throw statement for errors, the call to the potentially offending function should be placed within a _____ block
A. throw
B. Try
C. catch
D. Scope
Answer & Explanation
Answer: Option B
18. The scope resolution operator is
A. a comma
B. a semicolon
C. a colon
D. two colons
Answer & Explanation
Answer: Option D
19. "C++" is a _____ constant
A. character literal
B. named literal
C. numeric literal
D. string literal
Answer & Explanation
Answer: Option D
20. In a C++ program, which of the following can be thrown?
A. scalar variables
B. programmer-defined objects
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option B
21. The items listed in the function header are called _____
A. actual arguments
B. formal parameters
C. passed parameters
D. sent arguments
Answer & Explanation
Answer: Option B
22. A translator that notes whether you have used a language correctly may be called a _____
A. theasurus
B. Compiler
C. coder
D. Decoder
Answer & Explanation
Answer: Option B
23. The feature in object-oriented programming that allows the same operation to be carried out differently, depending on the object, is_____
A. inheritance
B. Polymorphism
C. overfunctioning
D. Overriding
Answer & Explanation
Answer: Option B
24. When an argument is passed by reference,
A. a variable is created in the function to hold the argument's value
B. the function cannot access the argument's value
C.
a temporary variable is created in the calling program to hold the argument's value
D. the function accesses the argument's original value in the calling program
E. None of the above
Answer & Explanation
Answer: Option D
25. The process of extracting the relevant attributes of an object is known as
A. Polymorphism
B. Inheritance
C. Abstraction
D. data hiding
Answer & Explanation
Answer: Option C
26. Which of the following statements uses the computer's clock to initialize the random number generator?
A. srand(time);
B. srand(time(NULL));
C. time(srand);
D. time(srand(NULL));
Answer & Explanation
Answer: Option B
27. A static data member is given a value
A. within the class definition
B. outside the class definition
C. when the program is executed
D. Never
Answer & Explanation
Answer: Option B
28. You must provide a constructor for a derived class
A. Always
B. if the base class constructor required arguments
C. if the base class constructor does not required arguments
D. Never
Answer & Explanation
Answer: Option B
29. If you want to override constructor default values for an object you are instantiating, you must also override
A. all other parameters to that constructor
B. all parameters to the left of that value
C. all parameters to the right of that value
D. no other parameters to that constructor
Answer & Explanation
Answer: Option B
30. To use one of the C++ built-in mathematical functions, you must include the _____ header file in your program
A. calculation.h
B. compute.h
C. expression.h
D. math.h
E. mathematical.h
Answer & Explanation
Answer: Option D
31. Errors in a program are called
A. Accidents
B. Annoyances
C. Bugs
D. Mistakes
E. typing errors
Answer & Explanation
Answer: Option C
32. If you declare two objects as Customer firstCust, secondCust; which of the following must be true?
A.
Each object's nonstatic data members will be stored in the same memory location
B. Each object will be stored in the same memory location
C. Each object will have a unique memory address
D. You cannot declare two objects of the same class
Answer & Explanation
Answer: Option C
33. Which of the following is the inequality operator?
A. != B. =
C. == D. -->
E. <> Answer & Explanation
Answer: Option A
34. If a derived class uses the public access specifier, then _____
A. public base class members remain public in the derived class
B. protected base class members become public in the derived class
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option A
35. The operator that releases previously allocated memory is _____
A. release
B. Return
C. delete
D. Destroy
Answer & Explanation
Answer: Option C
36. When a language has the capability to produce new data types, it is said to be
A. reprehensible
B. Encapsulated
C. overloaded
D. Extensible
Answer & Explanation
Answer: Option D
37. A compound statement does not consist of
A. a single statement
B. other compound statements
C. expression statements
D. control statements
E. None of the above
Answer & Explanation
Answer: Option A
38. Which of the following statements will display the word "Hello" on the computer screen?
A. cin << "Hello";
B. cin >> "Hello";
C. cout << "Hello";
D. cout >> "Hello";
E. None of the above
Answer & Explanation
Answer: Option C
39. The preprocessor directive always starts with the symbol
A. %
B. &
C. #
D. ""
E. None of the above
Answer & Explanation
Answer: Option C
40. Which of the following statements is true?
A. Data coupling is tighter than pathological coupling
B. Common coupling is looser than data coupling
C. Data-structured coupling is looser than control coupling
D. Control coupling is looser than data coupling
Answer & Explanation
Answer: Option C
41. Evaluate the following expression: 7 >=3 + 4 || 6<4 && 2<5
A. True
B. False
Answer & Explanation
Answer: Option A
42. The base class for most stream classes is the _____ class
A. ios
B. Out
C. in
D. App
Answer & Explanation
Answer: Option A
43. Which of the following while clause will stop the loop when the value in the age variable is less than the number 0?
A. while age < 0
B. while (age < 0)
C. while age >= 0;
D. while (age >= 0);
E. while (age >= 0)
Answer & Explanation
Answer: Option E
44. The most efficient data type for a variable that stores the number 4.6e20 is the _____ data type
A. Character
B. Double
C. Float
D. Long Integer
E. Short Integer
Answer & Explanation
Answer: Option C
45. Which of the following is a C++ object?
A. cin
B. >>
C. iostream
D. read()
Answer & Explanation
Answer: Option A
46. Which of the following can be used to declare the main function?
A. void main
B. void Main()
C. void main()
D. Main
E. either (b) or (c) can be used
Answer & Explanation
Answer: Option C
47. You _____ write your own container classes
A. Must
B. May
C. should not
D. must not
Answer & Explanation
Answer: Option B
48. If an integer object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is
A. Int
B. Double
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option A
49. The highest level of cohesion is
A. functional cohesion
B. temporal cohesion
C. logical cohesion
D. sequential cohesion
Answer & Explanation
Answer: Option A
50. You separate a derived class name from its access specifier with
A. a colon
B. two colons
C. at least one space
D. a semicolon
Answer & Explanation
Answer: Option C
1. The last statement in a function is often a(n) _____
A. return
B. Goodbye
C. finish
D. Endfunction
Answer & Explanation
Answer: Option A
2. When the function int someFunction(char c) throw( ) is executed, _____
A. it can throw anything
B. it may throw an integer
C. it may throw a character
D. it may not throw anything
Answer & Explanation
Answer: Option D
3. The two statements that can be used to change the flow of control are
A. if and switch
B. if and while
C. switch and do-while
D. break and continue
E. None of the above
Answer & Explanation
Answer: Option A
4. If p and q are assigned the values 2 and 3 respectively then the statement p = q++
A. gives an error message
B. assigns a value 4 to p
C. assigns a value 3 to p
D. assigns a value 5 to p
E. None of the above
Answer & Explanation
Answer: Option C
4. If p and q are assigned the values 2 and 3 respectively then the statement p = q++
A. gives an error message
B. assigns a value 4 to p
C. assigns a value 3 to p
D. assigns a value 5 to p
E. None of the above
Answer & Explanation
Answer: Option C
6. If you want only one memory location to be reserved for a class variable, no matter how many objects are instantiated, you should declare the variable as
A. static
B. Unary
C. dynamic
D. Volatile
Answer & Explanation
Answer: Option A
7. To use a template class member function, use the ________ with the instantiation
A. scope resolution operator
B. dot operator
C. class definition
D. keword template
Answer & Explanation
Answer: Option B
8. When a class is derived from another derived class, the newly derived class
A.
may have more liberal access to a base class member than its immediate predecessor
B.
may have the same type of access to a base class member as its immediate predecessor
C.
may have more limited access to a base class member than its immediate predecessor
D. both (b) and (c)
Answer & Explanation
Answer: Option C
9. If you assign a default value to any variable in a function prototype's parameter list, then _____
A. all other parameters in the function prototype must have default values
B. all parameters to the right of that variable must have default values
C. all parameters to the left of that variable must have default values
D. no other parameters in that prototype can have default values
Answer & Explanation
Answer: Option B
10. The dot operator (or class member access operator) connects the following two entities (reading from left to right):
A. a class member and a class object
B. a class object and a class
C. a class and a member of that class
D. a class object and a member of that class
Answer & Explanation
Answer: Option D
11. Which of the following calls a function named displayName, passing it no actual arguments?
A. call displayName;
B. call displayName ();
C. displayName;
D. displayName();
Answer & Explanation
Answer: Option D
12. The feature that allows you to use the same function name for separate functions that have different argument lists is called _____
A. overriding B. Overloading
C. constructing D. Destructing
Answer & Explanation
Answer: Option B
13. Which of the following are valid characters constants?
A. '\n'
B. '\\'
C. '\0'
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option D
14. With a template class, _____ type is generic
A. No
B. exactly one
C. at least one
D. at most one
Answer & Explanation
Answer: Option C
15. If you want to use a class to define objects in many different programs, you should define the class in a C++ _____ file
A. header
B. program
C. source
D. text
Answer & Explanation
Answer: Option A
16. Functions that returns information about an object's state can be classified as ________
A. inspector functions
B. mutator functions
C. auxiliary functions
D. manager functions
Answer & Explanation
Answer: Option A
17. An auxiliary function _____
A. return information about data members
B. changes the state of data members
C. performs an action or service
D. creates and destroys objects
Answer & Explanation
Answer: Option C
18. To create and execute a C++ program, you need to have access to
A. a C++ compiler
B. a C++ translator
C. an object code editor
D. a text editor
E. both (a) and (d)
Answer & Explanation
Answer: Option E
19. If you omit any constructor argument when you instantiate an object, you must use default values______
A. for all parameters to the constructor
B. for all parameters to the right of the argument
C. for all parameters to the left of the argument
D. for no other parameters
Answer & Explanation
Answer: Option B
20. Many programmers separate a class into two files: _____
A. one for the declarations and one for the implementations
B. one for the void functions and one for the other functions
C. one for the public data and one for the private data
D. one for the primary functions and one for the auxiliary functions
Answer & Explanation
Answer: Option A
21. Files whose names end in .h are called _____ files
A. handy
B. header
C. helper
D. helping
Answer & Explanation
Answer: Option B
22. When accessing a structure member, the identifier to the left of the dot operator is the name of
A. a structure member
B. a structure tag
C. a structure variable
D. the keyword struct
Answer & Explanation
Answer: Option C
23. Assume that a program contains a programmer-defined void function. When C++ encounters the function's closing brace (}), C++ returns to the statement _____
A. immediately above the statement that called the function
B. that called the function
C. immediately below the statement that called the function
Answer & Explanation
Answer: Option C
24. Inheritance occurs when a class adopts all the traits of _________
A. an object
B. a parent class
C. a variable
D. a function
Answer & Explanation
Answer: Option B
25. Template classes that have already been written to perform common class tasks are called _____
A. container classes
B. receptacle classes
C. repository classes
D. alembic classes
Answer & Explanation
Answer: Option A
26. A _____ is a single item of information about a person, place, or thing
A. data file
B. field
C. program file
D. record
Answer & Explanation
Answer: Option B
27. Which (if any) of the following is NOT a programmer-defined type
A. an array
B. a structure
C. a class
D. All of the above are programmer-defined types
Answer & Explanation
Answer: Option D
28. Assume a program contains a void function named displayName, which requires no formal parameters. Which of the following is a correct function prototype for this function?
A. displayName;
B. displayName(void);
C. void displayName;
D. void displayName();
E. void displayName(none);
Answer & Explanation
Answer: Option D
29. A file pointer always contains the address of the file
A. True
B. False
Answer & Explanation
Answer: Option B
30. You declare a function with a function _____, which is typically entered at the beginning of the program, below the #include directives
A. call
B. prototype declaration
C. definition
D. pointer
Answer & Explanation
Answer: Option B
31. The function whose prototype is Item getData(void); returns _____
A. the address of a structure
B. a copy of a structure
C. a pointer to a structure
D. nothing
Answer & Explanation
Answer: Option D
32. Using new may result in less _____ memory than using an array
A. wasted B. used
C. RAM D. ROM
Answer & Explanation
Answer: Option A
33. The most common operation used in constructors is
A. addition
B. overloading
C. assignment
D. polymorphism
Answer & Explanation
Answer: Option C
34. In a simple 'if' statement with no 'else'. What happens if the condition following the 'if is false?
A. the program searches for the last else in the program
B. nothing
C. control 'falls through' to the statement following 'if
D. the body of the statement is executed
E. None of the above
Answer & Explanation
Answer: Option C
35. If two types of errors may be thrown, you should write _______
A. no catch blocks
B. one catch block with two arguments
C. two catch block-one with an argument, and one without
D. two catch blocks with one argument each
Answer & Explanation
Answer: Option D
36. The name of a function ends with
A. double quotes
B. single quotes
C. parenthesis
D. #
E. None of the above
Answer & Explanation
Answer: Option C
37. Which of the following is not a programming control structure?
A. repetition
B. selection
C. sequency
D. sorting
Answer & Explanation
Answer: Option D
38. The bitwise OR operator is a
A. unary operator
B. binary operator
C. ternary operator
D. octal operator
E. None of the above
Answer & Explanation
Answer: Option B
39. A class Stockltems has four data members and three function members. You define 50 objects as members of the class. Which is true?
A. Only one copy of each of the tnree functions exists
B. Only one copy of each of the four data members exists
C. Both (a) and (b) are true
D. Neither (a) nor (b) is true
Answer & Explanation
Answer: Option A
40. The continue statement should be written only
A. in the body of a loop.
B. in the nested loops
C. outside the body of a loop
D. any where
E. None of the above
Answer & Explanation
Answer: Option A
41. A major advantage of inheritance is
A. reducing the time it takes to create new objects
B. not having to think about how objects will be used
C. reducing the amount of memory required to execute a progrma
D.
enabling people who have not studied programming to create useful applications
Answer & Explanation
Answer: Option A
42. When a variable exists or is accessible, it is said to be _____
A. immediate
B. in the path
C. available
D. in scope
Answer & Explanation
Answer: Option D
43. The feature that allows the same operations to be carried out differently depending on the object is _____
A. polymorphism
B. polygamy
C. inheritane
D. multitasking
Answer & Explanation
Answer: Option A
44. Which of the following is a C++ class?
A. >>
B. read()
C. cin
D. iostream
Answer & Explanation
Answer: Option D
45. Precedence determines which operator
A. is evaluated first
B. is most important
C. is fastest
D. operates on the largest number
E. None of the above
Answer & Explanation
Answer: Option A
46. When using the standard files that come with the C++ compiler, you should surround the header file name with _____
A. square brackets
B. angle brackets
C. parentheses
D. quotes
Answer & Explanation
Answer: Option B
47. The loop condition in a flowchart is represented by a(n) _____
A. diamond
B. oval
C. parallelogram
D. rectangle
Answer & Explanation
Answer: Option A
48. Which of the following, if any, are invalid names for a variable?
A. bankAccountNumber
B. first_Name
C. doubleNumber
D. operator
E. All of the above are valid names for variables
Answer & Explanation
Answer: Option D
49. Inheritance is the principle that
A. classes with the same name must be derived from one another
B. knowledge of a general category can be applied to more specific objects
C. C++ functions may be used only if they have logical predecessors
D. one function name may invoke different methods
Answer & Explanation
Answer: Option B
1. You typically initialize a String variable to _____
A. an asterisk
B. a space enclosed in single quotes
C. the number 0
D. a zero-length string
Answer & Explanation
Answer: Option D
2. The set of instructions for how to tie a bow is an example of the _____ structure
A. control B. repetition
C. selection D. sequence
E. switching Answer & Explanation
Answer: Option D
3. If no exception is thrown ________
A. a catch block will cause an error
B. the first catch block coded will execute
C. the last catch block coded with execute
D. any catch blocks coded with be bypassed
Answer & Explanation
Answer: Option D
4. A program that predicts the exact sequence in which events will take place is said to be ________
A. compiled B. interpreted
C. procedural D. object-oriented
Answer & Explanation
Answer: Option C
5. A blueprint for creating an object in C++ is called _____
A. a class
B. an instance
C. a map
D. a pattern
E. a sketch
Answer & Explanation
Answer: Option A
6. The prototype for a derived class constructor may include arguments for
A. data members of the derived class
B. data members of the base class
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
7. Overloading involves writing two or more functions with ________
A. different names and different argument lists
B. different names and the same argument list
C. the same name and different argument lists
D. the same name and the same argument list
Answer & Explanation
Answer: Option C
8. You___________overload function templates
A. may, as long as each version has the same arguments
B. may, as long as each version has different arguments
C. must
D. must not
Answer & Explanation
Answer: Option B
9. You typically initialize Character variables to _____
A. a space enclosed in double quotes
B. a space enclosed in single quotes
C. the letter O
D. the number 0
E. the value false
Answer & Explanation
Answer: Option B
10. One way pointers are useful is to refer to a memory address that has no _____
A. name B. constant
C. location D. field
Answer & Explanation
Answer: Option A
11. A member function uses the correct object when you call it because
A. a copy of the object is passed to the function
B. the address of the object is passed to the function
C. the address of the function is passed to another function
D. the address of the object is returned from the function
Answer & Explanation
Answer: Option B
12. Two access specifiers in C++ are
A. public and private
B. int and double
C. formal and informal
D. void and free
Answer & Explanation
Answer: Option A
13. Which of the following is the fourth problem-solving step?
A. analyze the problem
B. evaluate and modify (if necessary) the program
C. code the algorithm
D. plan the algorithm
E. desk-check the program
Answer & Explanation
Answer: Option C
14. Within parentheses, catch blocks can have _____
A. no arguments
B. one argument
C. two arguments
D. as many arguments as necessary
Answer & Explanation
Answer: Option B
15. The while loop is referred to as a(n) _____ loop because the loop condition is tested at the beginning of the loop
A. beginning B. initial
C. pretest D. priming
Answer & Explanation
Answer: Option C
16. The word case used in the switch statement represents a
A. function in the C++ language
B. data type in the C++ language
C. keyword in the C++ language
D. global variable in the C++ language
E. None of the above
Answer & Explanation
Answer: Option C
17. Function templates _____________
A. must have exactly one parameter
B. may have more than one parameter as long as they are of the same type
C. may have more than one parameter of any type
D. may not have parameters
Answer & Explanation
Answer: Option C
18. The statement int num[2][3]={ {3,8,6}, {9,4,7}};
A. assigns a value 4 to num[1][2]
B. assigns a value 7 to num[1][2]
C. assigns a value 8 to num[1][2]
D. assigns a value 9 to num[1][2]
Answer & Explanation
Answer: Option B
19. Private data can be accessed by
A. class member functions
B. functions in derived classes
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option A
20. The store of memory available to programs is the _____
A. store B. stack
C. pile D. heap
Answer & Explanation
Answer: Option D
21. The most common operation used in constructors is _____
A. addition
B. overloading
C. assignment
D. polymorphism
Answer & Explanation
Answer: Option C
22. When a function performs tasks based on a decision, it has _____
A. functional cohesion
B. coincidental cohesion
C. logical cohesion
D. no cohesion
Answer & Explanation
Answer: Option C
23. To create a template class, you begin with _________
A. the template definition
B. the keyword class
C. the function definitions
D. the keyword definition
Answer & Explanation
Answer: Option A
24. Which of the following is a C++ object?
A. >>
B. read()
C. cin
D. iostream
Answer & Explanation
Answer: Option C
25. A variable is _____
A. an item of data
B. a memory location whose value can change while the program is running
C. a memory location whose value cannot change while the program is running
Answer & Explanation
Answer: Option B
26. A function can
A. return a value
B. perform a task
C. change value of actual arguments in call by reference
D. a, b, c above are all true
E. None of the above
Answer & Explanation
Answer: Option D
27. The statement float values[]={3.14, -7.86, 36.96, 4.87};
A. assigns 36.96 to values[2]
B. assigns -7.86 to values[2]
C. gives an error message
D. assign 14 to values[2]
Answer & Explanation
Answer: Option A
28. A constructor initialization list is preceded by _____
A. a semicolon
B. a colon
C. two colons
D. a space
Answer & Explanation
Answer: Option B
29. When the compiler places a copy of a small function's statements directly into a program, the function is said to be _____
A. overloaded
B. mangled
C. inline
D. redundant
Answer & Explanation
Answer: Option C
30. A group of related fields that contain all of the data about a specific person, place, or thing is called a
A. data file
B. field file
C. program file
D. record
Answer & Explanation
Answer: Option D
31. To send output to a file, you need to include the _____ header file in your program
A. file.h
B. fstream.h
C. iomanip.h
D. iostream.h
E. of stream.h
Answer & Explanation
Answer: Option B
32. A C++ _____ is a program that runs in a DOS window
A. algorithm
B. cast application
C. console application
D. source application
Answer & Explanation
Answer: Option C
33. A difference, between reference variables and pointers is that
A. reference variables are easier to use
B. pointers are easier to use
C. reference variables are more flexible
D. no difference exists between reference variables and pointers
Answer & Explanation
Answer: Option A
34. A 'C function does not contain
A. a function header
B. argument declarations
C. other 'C' functions
D. function body
E. None of the above
Answer & Explanation
Answer: Option C
35. _____ variables remain in memory until the program ends
A. Area
B. Global
C. Local
D. Reference
E. Value Answer & Explanation
Answer: Option B
36. The outline or the definition of a function is called its
A. beta test
B. forerunner
C. outline
D. prototype
Answer & Explanation
Answer: Option D
37. Which of the following is false?
A. Data stored in an array can be accessed faster than data stored in a disk file
B.
Data stored in an array needs to be entered only once, typically at the beginning of the program
C.
Arrays allow the programmer to store information in the computer's internal memory
D. When using arrays, you will have fewer variable names to remember
E. None of the preceding statements are false
Answer & Explanation
Answer: Option E
38. A function stub typically contains
A. the function header
B. the function braces
C. the return statement, if it's value- returning function
D. a display message
E. All of the above
Answer & Explanation
Answer: Option E
39. A variable's _____ indicates which portions of the program can use the variable
A. area
B. extent
C. lifetime
D. reach
E. scope Answer & Explanation
Answer: Option E
40. If an integer object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is _____
A. const int &
B. int &
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
41. _____ variables are declared outside of any statement block
A. Area
B. Global
C. Local
D. Reference
E. Value Answer & Explanation
Answer: Option B
42. The end of string is recognized by
A. the null character
B. the newline character
C. the $ sign
D. the / sign
E. None of the above
Answer & Explanation
Answer: Option A
43. Variable names known only to the procedure in which they are declared are ________
A. local
B. global
C. recent
D. internal
Answer & Explanation
Answer: Option A
44. Whis is true?
A. A derived class may have more than one base class
B. A base class may have more than one derived class
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
45. The keyword used to define a structure is
A. stru B. stt
C. struct D. unlimited
Answer & Explanation
Answer: Option C
46. If you omit any constructor argument when you instantiate an object, you must use default values
A. for all parameters to the constructor
B. for all parameters to the right of the argument
C. for all parameters to the left of the argument
D. for no other parameters
Answer & Explanation
Answer: Option B
47. The C++ expression p --> val means the same thing as
A. *p.val
B. *(p.val)
C. (*p).vai
D. p.val
Answer & Explanation
Answer: Option C
48. Which of the following tells C++ to display numbers with zero decimal places?
A. setiosflags(0) B. setiosflags(zero)
C. setprecision(0) D. setprecision(zero)
Answer & Explanation
Answer: Option C
49. Code that has already been tested is said to be _____
A. inherited B. reusable
C. reliable D. polymorphic
Answer & Explanation
Answer: Option C
1. If no constructors can specified for a derived class, objects of the derived class will use the constructors in the base class
A. True
B. False
Answer & Explanation
Answer: Option A
2. The get() function returns _____
A. a character
B. void
C. a reference to the object that invoked it
D. a copy of the object that invoked it
Answer & Explanation
Answer: Option C
3. The most efficient data type for a variable that the number 20000 is the _____ data type
A. Character
B. Double
C. Float
D. Long Integer
E. Short Integer
Answer & Explanation
Answer: Option E
4. The number 5.5e3 is a _____ constant
A. character literal
B. named literal
C. numeric literal
D. string literal
Answer & Explanation
Answer: Option C
5. The compiler determines the type used in a template function via ___________
A. the name of the function
B. the first variable declared within the function
C. the type of the argument passed to the function
D. the type of the value returned from the function
Answer & Explanation
Answer: Option C
6. Simple routines that programmers use as place holders while a system is being tested are called _____
A. stubs B. stumps
C. holders D. templates
Answer & Explanation
Answer: Option A
7. You can place function templates
A. at the end of main()
B. at the start of a program above main()
C. in two files-one for the definition and one for the function
D. any of the above
Answer & Explanation
Answer: Option B
8. The two operators && an || are
A. arithmetic operators
B. equality operators
C. logical operators
D. relational operators
E. None of the above
Answer & Explanation
Answer: Option C
9. The arguments that determine the state of the cout object are called _____
A. classes
B. manipulators
C. format flags
D. state controllers
Answer & Explanation
Answer: Option C
10. Static variables are sometimes called
A. class variables
B. functional variables
C. dynamic variables
D. auto variables
Answer & Explanation
Answer: Option A
11. The variables declared in a statement block or listed in a function header's parameterlist are considered _____ variables
A. area B. global
C. local D. reference
E. value Answer & Explanation
Answer: Option C
12. An expression
A.
is a collection of data objects and operators that can be evaluated to a single value
B. is a name that substitutes for a sequence of characters
C. causes the computer to carry out some action
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option A
13. In the C language, the character type of constant is delimited by using
A. single quotes
B. double quotes
C. parenthesis
D. #
E. None of the above
Answer & Explanation
Answer: Option A
14. One way in which a structure differs from an array is that _____
A. a structure may have members of more than one type
B. a structure must have members that; are all the same type
C. art array may have members of more than one type
D. there is no difference between a structure and an array
Answer & Explanation
Answer: Option A
15. A default constructor _____
A. takes no arguments
B. has default values for all its arguments
C. either (a) or (b)
D. neither (a) nor (b).
Answer & Explanation
Answer: Option C
16. The number 125.35 is a _____
A. character literal constant
B. numeric literal constant
C. string literal constant
D. variable
Answer & Explanation
Answer: Option B
17. When a class serves as a base class to others, _____
A. all of its members are inherited
B. all of its members are inherited, except for any private members
C. all of its members are inherited, except for any protected members
D. None of its members is inherited unless specifically "listed
Answer & Explanation
Answer: Option B
18. Storing a class definition in a separate file is an example of
A. polymorphism
B. name mangling
C. implementation hiding
D. inheritance
Answer & Explanation
Answer: Option C
19. Which is true?
A. Sequential cohesion is slightly weaker than functional cohesion
B. Sequential cohesion is slightly stronger than functional cohesion
C. Sequential cohesion is much stronger than functional cohesion
D. Neither sequential cohesion nor functional cohesion is stronger than the other
Answer & Explanation
Answer: Option A
20. A class named student must have a constructor whose name is
A. student
B. ~student
C. constructor
D. any legal C++ name.
Answer & Explanation
Answer: Option A
21. The statement double val[15]={44.123456};
A. assigns the value 44.123456 to all members of the array val
B. assigns the value 44.123456 to val[0] and 0 to the rest of the members
C. gives an error message
D. assigns the value 44.12345 to val[1] and val[5]
Answer & Explanation
Answer: Option B
22. Which of the following C++ expressions will find the square root of the number 16?
A. pow (16, 2) (b) root (16, 2)
B. sqroot (16)
C. sqrt (16, 2)
D. sqrt (16)
Answer & Explanation
Answer: Option D
23. It is illegal to make objects of one class members of another class
A. True
B. False
C. depends upon the kind of object
Answer & Explanation
Answer: Option B
24. Catch blocks must _____
A. appear in every object-oriented program
B. appear within try blocks
C. appear immediately after throw statements
D. appear immediately after try blocks
Answer & Explanation
Answer: Option D
25. An exception specification begins with the keyword _____
A. exception B. try
C. throw D. catch
Answer & Explanation
Answer: Option C
26. You construct a class in two sections, known as the _____
A. header and body
B. type and parameters
C. declaration and implementation
D. pointer and variable
Answer & Explanation
Answer: Option C
27. It is sometimes useful to specify a class from which no objects will ever be created
A. True
B. False
Answer & Explanation
Answer: Option A
28. The statement i*=3 is equivalent to
A. i = 3*
B. i = 3
C. i* = 3
D. i = i * 3
E. None of the above
Answer & Explanation
Answer: Option D
29. The complement operator is represented by the symbol
A. ~
B. ^
C. i
D. <
E. None of the above
Answer & Explanation
Answer: Option A
30. One of the relational operators in the C language is
A. !=
B. &&
C. !
D. #
E. None of the above
Answer & Explanation
Answer: Option A
31. Within a program, you can instantiate ________that have a class template type
A. classes B. functions
C. parameters D. objects
Answer & Explanation
Answer: Option D
32. The rules to any programming language are its _______
A. syntax B. interpretation
C. logic D. customs
Answer & Explanation
Answer: Option A
33. Which of the following backslash codes used for bell?
A. \b
B. a
C. \r
D. \s
E. None of the above
Answer & Explanation
Answer: Option B
34. The last statement in a value-returning function is always _____
A. };
B. result expression;
C. return;
D. return expression;
Answer & Explanation
Answer: Option D
35. One of the logical operators in the C language is represented by the symbol
A. AND
B. &&
C. >=
D. <=
E. None of the above
Answer & Explanation
Answer: Option B
36. Which of the following declares and initializes an Integer variable named numltems?
A. int numltems = 0;
B. int numltems = '0';
C. integer numltems = 0;
D. numltems int = 0;
E. numltems integer = 0;
Answer & Explanation
Answer: Option A
37. Which of the following tells C++ to display numbers in fixed notation?
A. setiosflags(fixed)
B. setiosflags(fixed: :is)
C. setiosflags(ios, fixed)
D. setiosflags(ios::fixed)
Answer & Explanation
Answer: Option D
38. The #include instruction is called a
A. direction
B. directive
C. merge instruction
D. statement.
Answer & Explanation
Answer: Option B
39. Another drawback to returning an error code from a function is that any error code
returned by the function
A. must be of the same type as return type of the function
B. must not be a character
C. cannot be checked in a main() program
D. can have multiple meanings
Answer & Explanation
Answer: Option A
40. Classes hold _____
A. data
B. methods
C. both data and methods
D. neither data nor methods
Answer & Explanation
Answer: Option C
41. In C++, the address operator is the following symbol _____
A. >>
B. &
C. *
D. !
Answer & Explanation
Answer: Option B
42. Which of the following is false?
A. A pointer variable contains the address of a variable in memory
B. You should both declare and initialize a pointer before you use it
C. Pointers are typically initialized to the empty string ("")
D.
A pointer's datatype must match the datatype of the variable to which it points
E. A pointer variable is typically referred to simply as a pointer
Answer & Explanation
Answer: Option C
43. The function that takes arguments to set the bits of cout is _____
A. setf() B. bitset()
C. ios() D. flat()
Answer & Explanation
Answer: Option A
44. When you declare a pointer, you must give it a _____
A. type
B. type and name
C. type, name, and value
D. name and value
Answer & Explanation
Answer: Option B
45. You typically initialize Short Integer, Integer, and Long Integer variables to
A. a space enclosed in double quotes
B. a space enclosed in single quotes
C. the letter O
D. the number 0
E. the value false
Answer & Explanation
Answer: Option D
46. Assume that a variable will need to store only integers in the range of 1 through 20000. The most efficient data type for the variable is _____
A. character
B. float
C. integer
D. long integer
E. short integer
Answer & Explanation
Answer: Option E
47. Which of the following is true?
A. iostream is derived from istream
B. iostream is derived from ostream
C. ostream is derived from iostream
D. ostream is derived from istream
Answer & Explanation
Answer: Option C
1. Which of the following are valid characters for a numeric literal constant?
A. a decimal point
B. the letter e
C. a minus sign
D. a plus sign
E. All of the above
Answer & Explanation
Answer: Option E
2. Any #include files may contain
A. constants
B. variables
C. functions
D. All of the above
Answer & Explanation
Answer: Option D
3. When a break statement is used in a loop, the control skips the rest of the statements in the loop after it and jumps
A. to the last lines in the program
B. to the next statement written after the body of the loop
C. to the first statement in the body of the loop
D. All. of the above
E. None of the above
Answer & Explanation
Answer: Option B
4. The function that takes arguments to set the bits of count is _____
A. setf() B. bitsef()
C. ios() D. flag()
Answer & Explanation
Answer: Option A
5. When two types are used in a function template and one is labeled T, the other
A. must also be named T
B. must be named U
C. can be any legal C++ identfier
D. it is illegal to have two types
Answer & Explanation
Answer: Option A
6. The best-written classes have
A. all functions private
B. all data public
C. no functions
D. None of the above
Answer & Explanation
Answer: Option D
7. Making class members inaccessible to nonmember functions is an example of
A. polymorphism
B. data hiding
C. redundancy
D. recursion
Answer & Explanation
Answer: Option B
8. Providing two or more constructors for the same class _____
A. requires different argument lists
B. requires different constructor names
C. requires different constructor types
D. is illegal
Answer & Explanation
Answer: Option A
9. 3 is a _____ constant
A. character literal
B. named literal
C. numeric literal
D. string literal
Answer & Explanation
Answer: Option C
10. _____ variables remain in memory until the statement block ends
A. Area
B. Global
C. Local
D. Reference
E. Value Answer & Explanation
Answer: Option C
11. An address is a _____ , while a pointer is a _____
A. array, variable
B. constant, variable
C. variable, position
D. variable, location
Answer & Explanation
Answer: Option D
12. Procedural cohesion is similar to sequential cohesion, except that with procedural cohesion _____
A. the tasks are not done in order
B. the tasks are simpler
C. the tasks share data
D. the tasks do not share data
Answer & Explanation
Answer: Option D
13. Which of the following creates an animal object named dog?
A. animal "dog";
B. animal dog;
C. dog "animal";
D. dog animal;
Answer & Explanation
Answer: Option B
14. The getline() function reads a line of text until _____
A. the length used as the second argument is reached
B. the character used as the third argument is reached
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
15. The extraction operator >> is a(n)
A. overloaded function
B. C++ class
C. C++ object
D. static reference variable
Answer & Explanation
Answer: Option A
16. One drawback to returning an error code from a function is _____
A. functions cannot return error codes
B. error codes must be integers, and some functions can't return an integer
C. a function can return only one value, so it can return only the error code
D. a function that returns an error code will identify all returns as errors
Answer & Explanation
Answer: Option C
17. Assuming the following three operators appear in an expression (without parentheses), which of the operators will be performed first?
A. && B. !
C. || Answer & Explanation
Answer: Option B
18. The code that you enter into a C++ program is called _____
A. console code
B. object code
C. project code
D. source code
Answer & Explanation
Answer: Option D
19. If a base class member is private, then
A.
if a derived class uses the public access specifier, the data member becomes public
B.
if a derived class uses the protected access specifier, the data member becomes protected
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option D
20. Which of the following instructions tells C++ to merge the source code from the iostream.h file into the current file?
A. #include <iostream.h>
B. #include iostream.h
C. #include <iostream.h>
D. #merge iostream.h
E. None of the above
Answer & Explanation
Answer: Option E
21. The statement double total = 0.0; performs _____
A. assignment B. initialization
C. rationalization D. polymorphism
Answer & Explanation
Answer: Option B
22. The two parts of a function are the
A. header and footer
B. declarations and statements
C. legs and feet
D. header and body
Answer & Explanation
Answer: Option D
23. The general principle underlying object-oriented error handling is that a called function should __________
A. neither check for, nor handle errors
B. check for errors but not be required to handle any detected
C. handle errors, but not check for them
D. both check for and handle errors
Answer & Explanation
Answer: Option B
24. Which of the following is false?
A. A void function's header begins with the keyword void
B.
A value-returning function's header begins with a data type, which represents the type of data the function will return
C.
Assuming displayAge is the name of a void function, displayAge(); is a both logically and syntactically valid C++ statement
D.
Assuming calcNewPrice is the name of a value-returning function, calcNewPriceO; is a both logically and syntactically valid C++ statement
E. Both void and value-returning functions can receive arguments.
Answer & Explanation
Answer: Option D
25. Reference variables and const class member
A. must be assigned values in any derived class
B. must never be initialized in a base class
C. must be initialized, rather than assigned values
D. must not exit if a class is to be a base class
Answer & Explanation
Answer: Option C
26. The actual arguments cannot he
A. a constant or a variable
B. of a different type from the corresponding formal arguments
C. other functions
D. expressions
E. None of the above
Answer & Explanation
Answer: Option B
27. The function stricmp("Jose", "JOSE") will return _____
A. - 1
B. 0
C. 1
Answer & Explanation
Answer: Option B
28. Which is true?
A. Coincidental cohesion is stronger than procedural cohesion
B. Logical cohesion is stronger than coincidental cohesion
C. Sequential cohesion is weaker than temporal cohesion
D. The weakest cohesion is functional
Answer & Explanation
Answer: Option B
29. A predefined function that may be used to handle memory allocation errors is
A. handle_error
B. set_new_handler
C. new_fix
D. memory_error
Answer & Explanation
Answer: Option B
30. A function in a derived class that has the same name as a function in the parent class _____
A. will cause an error message to display
B. will override the base class function
C. will be overridden by the base class function
D. will execute immediately after the base class function executes
Answer & Explanation
Answer: Option B
31. The _____ function returns the uppercase equivalent of a character
A. caseupper
B. charupper
C. toupper
D. uCase
E. upper Answer & Explanation
Answer: Option C
32. When you instantiate a derived class object, a constructor for the derived class _____
A. is not called
B. is called prior to the base class constructor
C. is called simultaneously with the base class constructor
D. None of the above
Answer & Explanation
Answer: Option D
33. A constructor may be _____
A. provided automatically by C++
B. written by you
C. either (a) or (b).
D. neither (a) nor (b).
Answer & Explanation
Answer: Option C
34. Software that can be used in applications other than the one for which it was originally written is called
A. recyclable B. inherited
C. reusable D. cheating
Answer & Explanation
Answer: Option C
35. Which of the following statements is false?
A. A class encapsulates all of an object's attributes and behaviors
B. An example of an attribute is the minutes variable in a time class
C. An example of a behavior is the setTime function in a time class
D. A class is considered an object
E. An object created from a class is referred to as an instance of the class
Answer & Explanation
Answer: Option D
36. Typing the function's name as Main, rather than main, is an example of
A. an entry error
B. a function error
C. a logic error
D. a syntax error
Answer & Explanation
Answer: Option D
37. When the compiler cannot differentiate between two overloaded constructors, they are called______
A. overloaded B. destructed
C. ambiguous D. dubious
Answer & Explanation
Answer: Option C
38. A function argument is
A. a variable in the function that receives a value from the calling program
B. a way that functions resist accepting the calling program's values
C. a value sent to the function by the calling program
D. a value returned by the function to the calling program
E. None of the above
Answer & Explanation
Answer: Option C
39. A function that is prototyped as double calculate(int num); may______
A. receive an integer constant such as 5
B. receive an integer variable
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
40. Passing a variable pointer as a constant _____
A. protects the contents pointed to by the pointer from change
B. eliminates the need to name the pointer in the function
C. eliminates the need to give the pointer a type in the function
D. causes a copy of the pointer to be produced in the function
Answer & Explanation
Answer: Option A
41. Recursive Functions
A. easier to code
B. executable faster than iterative ones
C. takes less main storage space
D. necessary to solve a certain class of problems
E. None of the above
Answer & Explanation
Answer: Option D
42. The purpose of a conditional operator is to
A. select one of the two values
B. select the highest of the two values
C. select one of the two values depending on a condition
D. select the more equal of the two values
E. None of the above
Answer & Explanation
Answer: Option C
43. Which of the following, if any, are valid names for variables?
A. amt.Sold
B. amt-Sold
C. amt_Sold
D. 98Sold
E. None of the above are valid names for variables
Answer & Explanation
Answer: Option C
44. Assume you want to compare the character stored in the initial variable to the letter a. Which of the following conditions should you use in the if statement? (Be sure the condition will handle a or A.)
A. (initial = 'a' or 'A')
B. (initial == 'a' or 'A')
C. (toupper(initial) = 'A')
D. (toupper(initial) == 'A')
Answer & Explanation
Answer: Option D
45. You can override a class's inherited access to make an individual member's access more ______
A. liberal
B. conservative
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option B
46. A class hierarchy
A. describes "is a kind of" relationships
B. describes "has a" relationships
C. shows the same relationships as an organization chart
D. shows the same relationships as a family tree
Answer & Explanation
Answer: Option A
47. Which of the following C++ expressions is equivalent to the mathematical expression 53 ?
A. 5 ^ 3
B. cube(5)
C. pow (3, 5)
D. pow(5, 3)
E. sqrt (5, 3)
Answer & Explanation
Answer: Option D
48. The right shift operator is represented by the symbol
A. >
B. >>
C. ->
D. <
E. None of the above
Answer & Explanation
Answer: Option B
49. In C++, class definitions are most often
A. stored with each program that uses them
B. stored in a header file that is included in the programs that use them
C. stored in a folder that you paste into every new project
D. retyped for every new project
Answer & Explanation
Answer: Option B
1. The comma operator (,) is primarily used in conjunction with
A. 'for' statement
B. 'if-else' statement
C. 'do-while' statement
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option A
2. To execute a C++ program, you first need to translate the source code into object code. This process is called
A. coding B. compiling
C. sourcing D. translating
Answer & Explanation
Answer: Option B
3. The rules of a programming language are called its _____
A. code B. guidelines
C. procedures D. regulations
E. syntax Answer & Explanation
Answer: Option E
4. An array element is accessed using
A. a first-in-first-out approach
B. the dot operator
C. a member name
D. an index number
Answer & Explanation
Answer: Option D
5. The program can access the private members of a class
A. directly
B. only through other private members of the class
C. only through other public members of the class
D.
None of the above - the program cannot access the private members of a class in any way
Answer & Explanation
Answer: Option C
6. To hide a data member from the program, you must declare the data member in the _____ section of the class
A. concealed B. confidential
C. hidden D. private
E. restricted Answer & Explanation
Answer: Option D
7. External documentation includes
A. a printout of the program's code
B. flowcharts
C. IPO charts
D. pseudocode
E. All of the above
Answer & Explanation
Answer: Option A
8. A function that is called automatically each time an object is created is a(n)
A. constructor B. contractor
C. builder D. architect
Answer & Explanation
Answer: Option A
9. A variable's _____ indicates how long the variable remains in the computer's memory
A. area
B. extent
C. lifetime
D. reach
E. scope Answer & Explanation
Answer: Option C
10. The function whose prototype is void getData(Item *thing); receives
A. a pointer to a structure
B. a reference to a structure
C. a copy of a structure
D. nothing
Answer & Explanation
Answer: Option A
11. You may override the class access specifier for_____
A. public members
B. public and protected members
C. any specific class members you choose
D. no clas smembers
Answer & Explanation
Answer: Option C
12. The null character needs a space of
A. zero bytes
B. one byte
C. three bytes
D. four bytes
E. None of the above
Answer & Explanation
Answer: Option B
13. The number of structures than can be declared in a single statement is
A. one B. two
C. three D. unlimited
Answer & Explanation
Answer: Option D
14. The cout << sales[0] + sales[1]; statement will______
A. display 22000
B. display 10000 + 12000
C. display sales[0] + sales[l]
D. result in an error
Answer & Explanation
Answer: Option A
15. The most efficient data type for a variable that stores the letter C is the _____ data type
A. Character
B. Double
C. Float
D. Long Integer
E. Short Integer
Answer & Explanation
Answer: Option A
16. The C++ operator used to allocate memory is _________
A. mem B. allocate
C. new D. create
Answer & Explanation
Answer: Option C
17. Assume that your version of C++ can recognize only the first 8 characters of an identifier name, through identifier names may be arbitrarily long. Which of the following identifier names is not distinct:
A. list, list2
B. address, Address
C. identifier_l, identifier_2
D. answer, ANSWER
E. None of the above
Answer & Explanation
Answer: Option C
18. Object is to class as _____
A. library is to book
B. mother is to daughter
C. Plato is to philosopher
D. president is to Lincoln
Answer & Explanation
Answer: Option C
19. A derived class may also be called a
A. subclass
B. super class
C. parent class
D. base class
Answer & Explanation
Answer: Option A
20. The C++ keyword for declaring a variable that contains a decimal point is _____
A. dec
B. decimal
C. float
D. floater
E. None of the above
Answer & Explanation
Answer: Option C
21. When you define an object that is a member of a class, such as Student Abby; _____
A.
a block of memory is set aside and all data members are assigned valid values
B. a block of memory is set aside
C. no memory is set aside until values are defined
D. no memory is set aside, but valid values are assigned to data members
Answer & Explanation
Answer: Option B
22. A program can directly access the _____ members of a class
A. hidden
B. private
C. public
D. both (b) and (c)
Answer & Explanation
Answer: Option C
23. Any output manipulator function you create _____
A. should take as an argument an instance of ostream as a reference
B. should return void
C. must be a member function of the ostream class
D. must inherit ostream
Answer & Explanation
Answer: Option A
24. To pass an array by reference, you
A. must include the address-of (&) operator before the array's name
B. must include the number symbol (#) before the array's name
C.
do not have to do anything because arrays are automatically passed by reference
Answer & Explanation
Answer: Option C
25. The instructions you enter into the computer are called the _____
A. edited code
B. machine code
C. object code
D. source code
Answer & Explanation
Answer: Option D
26. The String data type is an extension of the _____ data type
A. Character
B. Double
C. Letter
D. Long
E. Text Answer & Explanation
Answer: Option A
27. An advantage of using local variables is that _____
A. they are known to all functions in the file
B.
names used in one function do not affect data stored in variables with the same names in other functions
C.
values given to local variables are retained when those parameters go out of scope
D. the program does not become "crowded" with too many variable names
Answer & Explanation
Answer: Option D
28. The difference between a return and a throw is that _____
A. with a throw, no value can be sent
B. with a return, no value can be sent
C.
with a throw, execution takes place at the location from which the function was called
D.
with a return, execution takes place at the location from which the function was called
Answer & Explanation
Answer: Option D
29. Which is a good reason for passing a variable's address to a function?
A. the function will have a copy of the variable
B. the function cannot change the value of the variable in the calling function
C. C++ requires that all variables used in a function be passed by address
D. the function needs to change multiple variable values
E. the called function can change the value of the variable in the calling function
Answer & Explanation
Answer: Option E
30. The string HELLO WORLD needs
A. 11 bytes
B. 12 bytes
C. 10 Bytes
D. 8 bytes
E. None of the above
Answer & Explanation
Answer: Option A
31. Library header files usually contain
A. complete functions
B. parts of functions
C. function prototypes for functions stored in other files
D. function bodies, but not function headers
Answer & Explanation
Answer: Option C
32. A C++ term meaning "generic" is
A. argument
B. parameterized
C. universal
D. global
Answer & Explanation
Answer: Option B
33. Before object-oriented exception handling was practiced, _____
A. no run-time errors occurred
B. programmers could not deal with run-time errors
C. the most popular error-handling method was to terminate the program
D. the most popular error-handling method was to throw an exception
Answer & Explanation
Answer: Option C
34. The preprocessor directive always ends with
A. a comma
B. a semicolon
C. neither a semicolon nor a comma
D. "/"
E. None of the above
Answer & Explanation
Answer: Option C
35. A constructor initialization list produces similar results to
A. overriding B. assignment
C. redeclaring D. output
Answer & Explanation
Answer: Option B
36. Which of the following stream manipulators advances the cursor to the next line on the computer screen?
A. adin B. advin
C. edlin D. endl
E. lineadv Answer & Explanation
Answer: Option D
37. 6.5 is a _____ constant
A. character literal
B. named literal
C. numeric literal
D. string literal
Answer & Explanation
Answer: Option C
38. The time and memory involved in calling a function represent the function's _____
A. prototype
B. overhead
C. cost
D. burden
Answer & Explanation
Answer: Option B
39. Which function is most likely to have procedural cohesion?
A. main()
B. findSquareRoot()
C. getSaleSubtractDiscountAddTax()
D. openFiles()
Answer & Explanation
Answer: Option A
40. A pointer is
A. the address of a variable
B. an indication of the variable to be accessed next
C. a variable for storing addresses
D. the data type of an address variable
Answer & Explanation
Answer: Option C
41. The instruction "If it's raining outside, then take an umbrella to work" is an example of the _____ structure
A. control
B. repetition
C. selection
D. sequence
E. switching
Answer & Explanation
Answer: Option C
42. Which of the following statements will assign the address of the age variable to the agePtr pointer?
A. agePtr = &age;
B. agePtr = *age;
C. &agePtr = age;
D. *agePtr = age;
E. agePtr -> *age;
Answer & Explanation
Answer: Option A
43. The >> (extraction) operator stops reading characters from the keyboard as soon as the user _____
A. presses the Enter key
B. types a character that is inappropriate for the variable's data type
C. both (a) and (b)
Answer & Explanation
Answer: Option C
44. In the statement template<class T>,
A. T is a class
B. T is a scalar variable
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
45. The null character is represented by
A. \n
B. \0
C. \o
D. \r
E. None of the above
Answer & Explanation
Answer: Option B
46. The break statement is
A. a preprocessor directive
B. an operator in the C++ language
C. a keyword in the C++ language
D. switch in the C++ language
E. None of the above
Answer & Explanation
Answer: Option C
47. A variable w with a value 67 may be defined with _______
A. int w = 67;
B. int w(67);
C. int 67(w);
D. both (a) and (b), but not (c).
Answer & Explanation
Answer: Option D
48. An expression contains relational, assignment and arithmetic operators. In the absence of parentheses, the order of evaluation will be
A. assignment, relational, arithmetic
B. arithmetic, relational, assignment
C. relational, arithmetic, assignment
D. assignment, arithmetic, relational
E. None of the above
Answer & Explanation
Answer: Option B
49. The keyword virtual indicates that
A. a derived class has public access to a base class
B. more than one base class exists
C. a base class should be used only once in inheritance
D. a derived class should have more than one base class constructed
Answer & Explanation
Answer: Option C
50. If you declare two objects as Customer firstCust, secondCust; which of the following must be true?
A. Each object will store a separate copy of any static member data
B. Each object will store a separate copy of any member functions
C. Each object will store a separate copy of any nonstatic data members
D. You cannot declare two objects of the same class
Answer & Explanation
Answer: Option C
1. Variables that are declared in a block are known as _____ variables to that block
A. confined
B. local
C. global
D. immediate
Answer & Explanation
Answer: Option B
2. The pow and sqrt functions return a(n) _____ type number
A. double B. float
C. integer D. long
E. short Answer & Explanation
Answer: Option A
3. Declaring variables is advantageous because it
A.
avoids errors from misspelled variable names {b) helps the linker work efficiently
B. simplifies the writing of very short programs
C. All of the above
D. None of the above
Answer & Explanation
Answer: Option C
4. The generic name used for unexpected errors that occur during the execution of a program is
A. infractions
B. exceptions
C. deviations
D. anomalies
Answer & Explanation
Answer: Option B
5. You add the desired type to a specific template class instantiation by placing the type's name ______
A. between angle brackets
B. in parentheses
C. on a line by itself
D. immediately prior to the class name
Answer & Explanation
Answer: Option A
6. The switch variable can be of
A. int type only
B. char type only
C. both int as well as char type
D. float type only
E. None of the above
Answer & Explanation
Answer: Option C
7. Reference variables and const class members _____
A. must be assigned values in any derived class
B. must never be initialized in a base class
C. must be initialized, rather than assigned values
D. must not exist if a class is to be a base class
Answer & Explanation
Answer: Option C
8. You can code a default exception handler by creating a catch block
A. with no arguments
B. with a void argument
C. with an ellipsis as its argument
D. with an argument identical to that thrown
Answer & Explanation
Answer: Option C
Explanation:
9. Which of the following are void functions?
A. main
B. pow
C. sqrt
D. All of the above
Answer & Explanation
Answer: Option A
10. Hiding individual components of an entry is _____
A. polymorphism
B. encapsulation
C. scaling
D. not recommended in C++
Answer & Explanation
Answer: Option B
11. When all of the operations in a function contribute to the performance of only one task, a function has
A. singular cohesion
B. tight cohesion
C. functional cohesion
D. sequential cohesion
Answer & Explanation
Answer: Option C
12. A function that uses variable types is called __________
A. overloaded
B. a template function
C. a variable function
D. a virtual function
Answer & Explanation
Answer: Option B
13. Having more than one function with the same name is called
A. overloading
B. defaulting
C. casting
D. referencing
Answer & Explanation
Answer: Option A
14. An object is _____
A. a category of classes
B. a name given to a class
C. an instance of a class
D. the same as a class
Answer & Explanation
Answer: Option C
15. Two access specifers in C++ are
A. public and private
B. int and double
C. formal and informal
D. void and free
Answer & Explanation
Answer: Option A
16. A data member holds a 1 or 0 depending on whether taxes have been paid. The best identifier for this member is _____
A. taxes
B. paidTaxes
C. taxesArePaid
D. code
Answer & Explanation
Answer: Option B
17. Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access
A. public members of Base
B. protected members of Base
C. private members of Base
D. public members of Derv
Answer & Explanation
Answer: Option A
18. Which of the following is an access specifier?
A. particular B. shielded
C. protected D. safe
Answer & Explanation
Answer: Option C
19. Machine code is _____
A. edited code
B. source code
C. the 0s and 1s that the computer can understand
D. both (b) and (c)
Answer & Explanation
Answer: Option C
20. The contents of two pointers that point to adjacent of type float differ by
A. one bytes
B. two bytes
C. three bytes
D. four bytes
Answer & Explanation
Answer: Option D
21. Which of the following is a valid condition for an if statement? (The condition should be both syntactically and logically valid.)
A. (age) > 65
B. (age > 0 and < 10)
C. (sales > 500 && < 800)
D. (sales > 100 && sales <= 1000)
E. (sales > 100 || sales <= 1000)
Answer & Explanation
Answer: Option D
22. A pattern for creating an object is called a(n) _____
A. class B. attributes
C. private D. public
Answer & Explanation
Answer: Option A
23. An asterisk placed after a data type means .
A. array to
B. pointer to
C. address to
D. located to
Answer & Explanation
Answer: Option B
24. An object is a(n) _____ of a class
A. owner B. function
C. definition D. instance
Answer & Explanation
Answer: Option D
25. Which of the following statements creates and initializes a pointer named salesPtr?
A. salesPtr = NULL;
B. *salesPtr = "";
C. float &salesPtr = NULL;
D. float *salesPtr = "";
E. float *salesPtr = NULL;
Answer & Explanation
Answer: Option E
26. With communicational cohesion
A. a tasks and the data are related
B. the tasks are related; the data are not
C. the data are related; the tasks are not
D. the tasks and the data are unrelated
Answer & Explanation
Answer: Option C
27. The function printDataMembers() is mot likely a(n) ________
A. inspector functions
B. mutator functions
C. auxiliary functions
D. manager functions
Answer & Explanation
Answer: Option A
28. The data type listed at the beginning of a value-returning function's header indicates the type of data the function will _____
A. return
B. pass
C. receive
Answer & Explanation
Answer: Option A
29. The code class Descendant : virtual public Ancestor indicates that
A. the members of Ancestor will be included more than once in Descendant
B. the members of Ancestor will be included only once in Descendant
C. the members of Descendant will be included more than once in Ancestor
D. the members of Descendant will be included only once in Ancestor
Answer & Explanation
Answer: Option B
30. Inheritance is the principle that
A. Classes with the same name must be derived from one another
B. Knowledge of a general category can be applied to more specific objects
C. C++ functions may be used only if they have logical predecessors
D. One function name may invoke different methods
Answer & Explanation
Answer: Option B
31. Which of the following formulas can be used to generate random integers between 1 and 10?
A. 1 + rand() % (10 - 1 + 1)
B. 1 + (10 - 1 + 1) % rand()
C. 10 + rand() % (10 - 1 + 1)
D. 10 + rand() % (10 + 1)
Answer & Explanation
Answer: Option A
32. Format flags may be combined using the _____
A. bitwise OR operator(|)
B. logical OR operator (||)
C. bitwise AND operator (&)
D. logical AND operator (&&)
Answer & Explanation
Answer: Option A
33. Which of the following will store the number 320000 as a Float number?
A. counPop = (float) 3.2e5;
B. counPop = (float) 3.2e6;
C. counPop = (float) .32e5;
D. counPop = (float) .32e7;
E. counPop = (float) 3.2-e5;
Answer & Explanation
Answer: Option A
34. The arguments that determine the state of the cout object are called
A. classes
B. manipulators
C. format flags or state flags
D. state controllers
Answer & Explanation
Answer: Option C
35. If a class will serve as a base class, most often the base class data members are
A. private B. protected
C. public D. polymorphic
Answer & Explanation
Answer: Option C
36. You can use the C++ _____ function to assign a value to a String variable
A. assign
B. copy
C. string
D. strcopy
E. strcpy
Answer & Explanation
Answer: Option E
37. A measure of the strength of the connection between two functions is
A. cohesion B. coupling
C. dependence D. subjection
Answer & Explanation
Answer: Option B
38. The following statement where T is true and F is false T&&T||F&&T
A. is true
B. is false
C. is wrong
D. not applicable in C language
E. None of the above
Answer & Explanation
Answer: Option A
39. Which of the following statements declares a variable that can contain a decimal number?
A. dec payRate;
B. dec hourlyPay
C. float payRate
D. float hourlyPay;
E. None of the above
Answer & Explanation
Answer: Option D
40. The statement int num[2][3]={ {1,2}, {3,4}, {5, 6} };
A. assigns a value 2 to num[1][2]
B. assigns a value 4 to num[1][2]
C. gives an error message
D. assigns a value 3 to num[1][2]
Answer & Explanation
Answer: Option C
41. A program will have one function prototype for each function defined in the programmer-defined section of the program. (Assume that the programmer-defined section is located below the main function.)
A. true B. false
Answer & Explanation
Answer: Option A
42. The standard input stream, which refers to the keyboard, is called
A. cin
B. cout
C. stin
D. stout
E. None of the above
Answer & Explanation
Answer: Option A
43. If the code and fee arrays are parallel, the fee that corresponds to the code stored in the code[3] element is located in the _____ element
A. code[2]
B. code[3]
C. fee[2]
D. fee[3]
Answer & Explanation
Answer: Option D
44. Access specifiers are followed by
A. a comma
B. a semicolon
C. a colon
D. two colons
Answer & Explanation
Answer: Option C
45. Elements in an array are identified by a unique _____
A. data type
B. order
C. subscript
D. symbol
Answer & Explanation
Answer: Option C
46. To include the double quotes as part of the control string we use the symbol
A. %"
B. ""
C. \"
D. #
E. None of the above
Answer & Explanation
Answer: Option C
47. A C++ statement must end in a
A. : (column)
B. , (comma)
C. . (period)
D. ; (semicolon)
Answer & Explanation
Answer: Option D
48. Student senior(); is a(n)_________
A. constructor call with no arguments
B. object instantiation
C. constructor call with all default arguments
D. prototype for a function that returns a student object
Answer & Explanation
Answer: Option D
49. The statement int n[4] = {11, -13, 17, 105};
A. assigns the value -13 to [2]
B. assigns the value 17 to n[2]
C. is wrong; it gives an error message
D. assigns the value 18 to n[2]
Answer & Explanation
Answer: Option B
1. Programmer-defined functions can be
A. value-returning functions only
B. void functions only
C. either value-returning or void functions
Answer & Explanation
Answer: Option C
2. A class D can be derived from a class C, which is derived from a class B, which is derived from a class A
A. True B. False
Answer & Explanation
Answer: Option A
4. The number of the relational operators in the C language is
A. four
B. six
C. three
D. one
E. None of the above
Answer & Explanation
Answer: Option B
5. Which of the following tells C++ to display numbers with two decimal places?
A. setdecimal(2)
B. setiosflags(2)
C.
6. A function that is called automatically each time an object is destroyed is a
A. constructor B. destructor
C. destroyer D. terminator
Answer & Explanation
Answer: Option B
7. We can output text to an object of class ofstream using the insertion operator « because
A. the ofstream class is a stream
B.
the insertion operator works with all classes
C.
we are actually outputting to cout
D.
the insertion operator is overloaded in ofstream
Answer & Explanation
Answer: Option D
8. The operator that allocates new memory is _____
A. allocate
B. mem
C. new
D. next
Answer & Explanation
Answer: Option C
9. A comment
A.
is a note that can be put into the source code
B. is ignored by the compiler.
C.
starts with the /* character pair
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option D
10. Which of the following is(are) valid identifier(s)?
A. record_1
B. 1 record
C. return
D. $tax
E. None of the above
Answer & Explanation
Answer: Option A
11. The functions go in the _____ section of a class definition
A. declaration B. implementation
C. prototype D. functioning
Answer & Explanation
Answer: Option B
12. You can throw _____
A. a scalar variable
B. a constant
C. a programmer-defined class object
D. any of these
Answer & Explanation
Answer: Option D
13. You invoke a function with a function
A. call B. declaration
C. definition D. prototype
Answer & Explanation
Answer: Option A
14. Which is a good guideline for creating function names?
A. Use all lowercase letters to identify the functions as C++ functions
B. Use long names to reduce the likelihood of creating a duplicate function name
C. Use abbreviations as much as possible to save both keystrokes and memory
D. Avoid the use of digits because they are easily confused with letters
Answer & Explanation
Answer: Option D
15. Reserving memory during program execution is known as reserving it
A. dynamically B. statically
C. functionally D. powerfully
Answer & Explanation
Answer: Option A
16. "Rohan Motors" is a _____
A. character literal constant
B. numeric literal constant
C. string literal constant
D. variable
Answer & Explanation
Answer: Option C
17. A programming structure that contains data and a pointer to the next object is a
A. template
B. class
C. pointer class
D. linked list
Answer & Explanation
Answer: Option D
18. A variable declared in a function is called a(n) _____ variable
A. area B. global
C. local D. reference
E. value Answer & Explanation
Answer: Option C
19. When you write to a file rather than the screen, you use the C++ class _____
A. iostream B. filed
C. fstream D. diskclass
Answer & Explanation
Answer: Option C
20. Which of the following numerical value(s) is(are) invalid constant(s)?
A. 0.7
B. 9.3el2
C. 27,512
D. 12345678
E. None of the above
Answer & Explanation
Answer: Option C
21. To use the this pointer with a member function, you _____
A. declare this as static
B. declare this as global
C. define this as equal to the address of the appropriate object
D. do nothing; it is automatically supplied for you
Answer & Explanation
Answer: Option D
22. A function that is prototype as int calculate(int num); may
A. receive an integer variable named num from the main() program
B. receive any integer variable from the main() program
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
23. A do-while loop contains
A. only one statement between the do statement and the while statement
B. several statements between the do statement and the while statement
C. no statement at all between the do statement and the while statement
D. only two statement between the do statement and the while statement
E. None of the above
Answer & Explanation
Answer: Option B
24. The braces that surround the code in a 'C program
A. show what code goes in a particular function
B. delimit a section of code
C. separate the codes from the constant
D. separate the source file from the subject file
E. None of the above
Answer & Explanation
Answer: Option B
25. The indirection operator is the
A. asterisk
B. ampersand
C. dollar sign
D. plus sign
Answer & Explanation
Answer: Option A
26. Local variables _____
A. are created outside a block
B. are known only to that block
C. continue to exist when their block ends
D. are illegal in C++
Answer & Explanation
Answer: Option B
27. # directives must be present
A. before the main() function
B. after the main() function
C. at the end of the program
D. anywhere in the program body
E. None of the above
Answer & Explanation
Answer: Option A
28. Programmers prefer to declare almost all variables _____
A. at the beginning of each function
B. globally
C. on one line
D. with cryptic names
Answer & Explanation
Answer: Option A
29. A(n) _____ is always incremented by a constant amount, whereas a(n) _____ is incremented by an amount that varies
A. accumulator, counter
B. counter, accumulator
Answer & Explanation
Answer: Option B
30. The C++ _____ function generates random numbers
A. generate() B. genRand
C. rand D. randGen
E. srand Answer & Explanation
Answer: Option E
31. You have declared an integer pointer called point You have also declared an integer called number. Which statement is the correct format?
A. point = number;
B. point = *number;
C. point = &number;
D. point = +number;
Answer & Explanation
Answer: Option C
32. If you wanted to sort many large objects or structures, it would be most efficient to
A. place them in an array and sort the array
B. place pointers to them in an array and sort the array
C. place them in a linked list and sort the linked list
D. place references to them in an array and sort the array
Answer & Explanation
Answer: Option B
33. A function that is prototyped as double calculate(int num); may ______
A. receive a double constant such as 3.9
B. receive a double variable
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option D
34. The printer can be accessed using the predefined filename _____
A. printer file
B. print
C. cout
D. PRN, LPT1, etc
Answer & Explanation
Answer: Option D
35. The best functions have _____
A. high cohesion and tight coupling
B. high cohesion and loose coupling
C. low cohesion and tight coupling
D. low cohesion and loose coupling
Answer & Explanation
Answer: Option B
36. One of the valid escape sequences used in the C language is
A. \z
B. \N
C. \t
D. \s
E. None of the above
Answer & Explanation
Answer: Option C
37. A default constructor
A. takes no arguments
B. has default values for all its arguments
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
38. Which of the following will increase the value stored in the first element of the fee array by 2?
A. amount[0] = amount[0] + 2;
B. amount, fee[0] = amount, fee [0] + 2;
C. feelnfo.amount[0] = feelnfo.amount[0] + 2;
D. fee[0].amount = fee[0].amount + 2;
E. fee.amount[0] = fee.amount[0] + 2;
Answer & Explanation
Answer: Option D
39. Which loop always processes its instructions at least once?
A. do-while
B. for
C. while
Answer & Explanation
Answer: Option A
40. When a new class is derived from an existing class, the derived class member functions _____ have names that differ from base class function names
A. may
B. may if the two classes have the same name
C. must
D. must not
Answer & Explanation
Answer: Option A
41. A static data member is given a value
A. within the class definition
B. outside the class definition
C. when the program is executed
D. never
Answer & Explanation
Answer: Option B
42. _____ refers to the process of locating and removing the errors in a program
A. Analyzing B. Correcting
C. Debugging D. Executing
E. Tracking Answer & Explanation
Answer: Option C
43. Static variables are sometimes called
A. class variables
B. functional variables
C. dynamic variables
D. auto variables
Answer & Explanation
Answer: Option A
44. You can pass _____ to functions
A. copies of individual structure members
B. copies of entire structures
C. pointers to structures
D. All of the above
Answer & Explanation
Answer: Option D
45. Element doubleArray[7] is which element of the array?
A. the sixth
B. the seventh
C. the eighth
D. impossible to tell
Answer & Explanation
Answer: Option C
46. Which of the following statements opens a file named temp.dat for output?
A. outFile.open("temp .dat");
B. fileOut.output("temp .dat");
C. openFile.out("temp .dat");
D. fileOpen.out("temp .dat");
E. out.fileOpen("temp .dat");
Answer & Explanation
Answer: Option A
47. Which of the following will store the letter H in a Character variable named initial?
A. initial = 'H'
B. initial = 'H';
C. initial = "H"
D. initial = "H";
Answer & Explanation
Answer: Option B
48. Compared with the classes from which they are derived, inherited classes may have _____
A. additional data members
B. additional member functions
C. both (a) and (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option C
49. A class named Student must have a constructor whose name is
A. Student
B. ~Student
C. constructor
D. any legal C++ name
Answer & Explanation
Answer: Option A
50. To write data that contains variables of type float, to an object of type ofstream, you should use
A. the insertion operator
B. seekg()
C. writeQ
D. put()
Answer & Explanation
Answer: Option C
1. The main difference in operation between an 'if statement and a 'while' statement is
A. the 'while' loop body is executed
B.
the body of the 'while' statement may be executed many times, the body of the 'if statements only once
C. the conditional expression following the keyboard is evaluated differently
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option B
2. If a class object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is_________
A. a parent class of the thrown class
B. a child class of the thrown class
C. either (a) or (b)
D. neither (a) nor (b)
Answer & Explanation
Answer: Option A
3. The weakest form of cohesion is
A. coincidental B. functional
C. logical D. communicational
Answer & Explanation
Answer: Option A
4. The 'continue' statement is used to
A.
permit two different expressions to appear in situations where only one expression would ordinarily be used
B. terminate loops or to exit from a switch
C.
alter the normal sequence of program execution by transferring control to some other part of the program
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option E
5. The 'break' statement is used to exist from
A. a do loop
B. a for loop
C. a switch statement
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option D
6. You have assigned the address of Value to the pointer P, Which statement will display the value stored in Value?
A. cout<<P; B. cout<<*Value;
C. cout<<&P; D. cout<<*P;
Answer & Explanation
Answer: Option D
7. A constructor initialization list is preceded by
A. a. semicolon
B. a colon
C. two colons
D. a space
Answer & Explanation
Answer: Option B
8. In C++, a function contained within a class is called
A. a member function
B. an operator
C. a class function
D. a method
Answer & Explanation
Answer: Option A
9. Which of the following statements will create and initialize a feelnfo array named fee?
A. fee feeInfo = {{0}, {0}};
B. fee as feeInfo = 0, 0;
C. feeInfo fee = 0, 0;
D. feeInfo fee = [{0}, {0}];
E. feeInfo fee = {0,0};
Answer & Explanation
Answer: Option E
10. Which of the following is the scope resolution operator?
A. ->>
B. ::
C. *
D. &
Answer & Explanation
Answer: Option B
11. If the description of function is "input the quantity, validate that the quantity is greater than 1, subtract 1 from the quantity, and print the quantity," the function is
A. sequentially cohesive
B. logically cohesive
C. communicationally cohesive
D. functionally cohesive
Answer & Explanation
Answer: Option B
12. A function that changes an object's state belongs to the category of
A. inspector functions
B. mutator functions
C. auxiliary functions
D. manager functions
Answer & Explanation
Answer: Option B
13. Which of the following pairs of identifier name(s) are(is) considered to be identical?
A. name, names
B. smith, johnsmith
C. identifier 1, identifier_2
D. charl, char_l
E. None of the above
Answer & Explanation
Answer: Option C
14. When you create a derived class and instantiate on object
A. the parent class object must be constructed first
B. the child class object must be constructed first
C. the parent class object must not be constructed
D. the child class object must not be constructed
Answer & Explanation
Answer: Option A
15. The int type of constants are whole numbers in the range
A. - 23677 to 23678
B. - 32768 to 32767
C. - 32767 to 32768
D. - 32864 to 32865
E. None of the above
Answer & Explanation
Answer: Option B
16. When the function char someFunction(int x) is executed,
A. it will throw nothing
B. it will throw an integer
C. it will throw a character
D. it may or may not throw anything
Answer & Explanation
Answer: Option D
17. One way in which a structure differs from an array is that
A. a structure may have members of more than one type
B. a structure must have members that are all the same type
C. an array may have members of more than one type
D. there is no difference between a structure and an array
Answer & Explanation
Answer: Option A
18. Variables that hold memory addresses are called _____
A. subscripts
B. holders
C. pointers
D. indicators
Answer & Explanation
Answer: Option C
19. The general form of do-while statement is
A. do expression while statement;
B. do while expression;
C. do statement while (expression);
D. do statement while statement;
E. None of the above
Answer & Explanation
Answer: Option C
20. The measure of how well the operations in a function relate to one another is _____
A. coupling
B. cohesion
C. adhesion
D. conversion
Answer & Explanation
Answer: Option B
21. If you want to override constructor default values for an object you are instantiating, you must also override
A. all other parameters to that constructor
B. all parameters to the left of that value
C. all parameters to the right of that value
D. no other parameters to that constructor
Answer & Explanation
Answer: Option B
22. An unsigned double type of data
A. can have only positive values
B. does not exist
C. is always less than 1010
D. can have only negative values
E. None of the above
Answer & Explanation
Answer: Option A
23. The extraction operator >> is a(n) _____
A. overloaded function
B. C++ class
C. C++ object
D. static reference variables
Answer & Explanation
Answer: Option A
24. Modules in C++ programs are
A. functions
B. procedures
C. subroutines
D. miniprograms
Answer & Explanation
Answer: Option A
25. The return type for all destructors is
A. the class
B. void
C. the same as the first data in the class
D. None
Answer & Explanation
Answer: Option D
26. If an exception is thrown and no catch block matches the type of the thrown parameter,
then _____
A. the program terminates
B. the first catch block is executed
C. the last catch block is executed
D. the program proceeds with the code following the catch blocks
Answer & Explanation
Answer: Option A
27. The comma operator (,) is used to
A.
permit two different expressions to appear in situations where only one expression would ordinarily be used
B. terminate loops or to exit from switch
C.
alter the normal sequence of program execution by transferring control to some other part of the program
D.
carry out a logical test and then take one of two possible actions, depending upon the outcome of the test
E. None of the above
Answer & Explanation
Answer: Option A
28. A function that is called automatically each time an object is created is a(n)
A. constructor
B. contractor
C. builder
D. architect
Answer & Explanation
Answer: Option A
29. Which of the following statements creates a named constant called driverAge whose value is 16?
A. const driverAge = 16;
B. const short driverAge = 16;
C. driverAge =16;
D. driverAge const =16;
E. namedconst driverAge =16;
Answer & Explanation
Answer: Option B
30. Which functions do not have a this pointer?
A. access functions
B. inspector functions
C. member functions
D. static functions
Answer & Explanation
Answer: Option D
31. When a program calls a function that has default parameters, if you omit an argument, you must _____
A. not omit any other arguments
B. omit all arguments
C. omit all arguments to the right of that argument
D. omit all arguments to the left of that argument
Answer & Explanation
Answer: Option C
32. Each generic type in a template function definition is preceded by the keyword _________
A. template
B. function
C. type
D. class
Answer & Explanation
Answer: Option A
33. The declaration section holds
A. data members
B. data members and function prototypes
C. data members, function prototypes, and the functions themselves
D. None of the above
Answer & Explanation
Answer: Option B
34. A derived class _____ override attributes of a parent class
A. may
B. may if the two classes have the same name
C. must
D. must not
Answer & Explanation
Answer: Option A
35. In object-oriented terms, an exception may be considered a(n) _____
A. child
B. encapsulation
C. message
D. scalar type
Answer & Explanation
Answer: Option C
Explanation: 36. A(n) _____ is a numeric variable used for counting something
A. accumulator B. adder
C. constant D. counter
E. integer Answer & Explanation
Answer: Option D
37. The element of an array is
A. the name of the array
B. a member of an array
C. a value assigned to an array
D. All of the above
Answer & Explanation
Answer: Option B
38. When the function void someFunction(int x) throw(char) is executed,_____
A. it will throw nothing
B. it may throw an integer
C. it may throw a character
D. it may not throw anything
Answer & Explanation
Answer: Option C
39. Which of the following is NOT included in the header of a function?
A. the type of variable returned by the function to the function that calls it
B. the name of the program or function that calls the function
C. the name of the function
D. the types and names of any variables that will be passed to the function
Answer & Explanation
Answer: Option B
40. If you want only one memory location to be reserved for a class variable, no matter how many objects are instantiated, you should declare the variable as________
A. dynamic B. unary
C. static D. volatile
Answer & Explanation
Answer: Option C
41. The logical NOT operator represented by is a
A. unary operator
B. binary operator
C. ternary operator
D. octal operator
E. None of the above
Answer & Explanation
Answer: Option A
42. When variables refer to attributes of an entity (such as name, address, and phone number of a person), those attributes form a _____
A. file B. record
C. field D. program
Answer & Explanation
Answer: Option B
43. A derived class _____ override attributes of a parent class
A. may
B. may if the two classes have the same name
C. must
D. must not
Answer & Explanation
Answer: Option A
44. Which of the following is false?
A. You enclose a function's statements in a set of braces
B.
The function header is considered a C++ statement, so it must end in a semicolon.
C.
The keyword void tells the C++ compiler that the function does not return a value
D. A function can receive information that you send (pass) to it
E.
An empty set of parentheses after the function's name in the function header tells you that the function does not receive any information
Answer & Explanation
Answer: Option B
45. A function's single most important role is to
A. give a name to a block of code
B. reduce program size
C. accept arguments and provide a return value
D. help organize a program into conceptual units
E. None of the above
Answer & Explanation
Answer: Option D
46. The delete operator returns ______ to the operating system
A. memory that is no longer needed
B. void
C. recycle bin
D. None of the above
Answer & Explanation
Answer: Option A
47. The major advantage of data hiding is that _____
A. your programs can include more data
B. you no longer need functions
C. no one can ever use your data
D. your data will be used correctly
Answer & Explanation
Answer: Option D
48. The letter V is a _____
A. character literal constant
B. numeric literal constant
C. string literal constant
D. variable
Answer & Explanation
Answer: Option A
49. Separating parts of a program into units that remain unaffected by other parts of a program is the concept known as _____
A. intrusion B. volatility
C. encapsulation D. protection
Answer & Explanation
Answer: Option C
1. A function whose purpose is to send messages to other functions is known as a _____
A. dispatcher B. courier
C. messenger D. sender
Answer & Explanation
Answer: Option A
2. With commercial classes, the function source code is usually________
A. printed on high-quality paper
B. poorly written
C. provided on a disk
D. provided in object form
Answer & Explanation
Answer: Option D
3. The type of value that a function sends back to the function that calls it is known as its _____
A. type
B. return value
C. reference data
D. sentinel
Answer & Explanation
Answer: Option B
4. Assume that a program includes the short *agePtr = NULL; statement. The name of the pointer is _____
A. *agePtr B. agePtr
Answer & Explanation
Answer: Option B
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
5. Which of the following are never inherited?
A. public data members
B. constructor functions
C. void functions
D. overloaded + operators
Answer & Explanation
Answer: Option B
6. The expression c = i++ causes
A. the value of i assigned to c and then i incremented by 1
B. i to be incremented by 1 and then the value of i assigned to c
C. value of i assigned to c
D. i to be incremented by 1
E. None of the above
Answer & Explanation
Answer: Option A
7. An identifier in C
A. is a name of a thing such as variable and function
B. is made up of letters, numerals, and the underscore
C. can contain both uppercase and lowercase letters
D. All of the above
E. None of the above
Answer & Explanation
Answer: Option D
8. Which of the following creates a String named constant called partNo, whose value is AB45?
A. const char[4] partNo = "AB45";
B. const char[5] partNo = 'AB45';
C. const char[5] partNo = "AB45";
D. const char partNo[5] = "AB45";
E. None of the above
Answer & Explanation
Answer: Option D
9. The bitwise AND operator is represented by the symbol
A. ^
B. &
C. &&
D. >>
E. None of the above
Answer & Explanation
Answer: Option B
10. The exclusive OR operator gives the result 1 when
A. both the bits are 0
B. one bit is 0 and the other is 1
C. both the bits are 1
D. no hard and fast rule
E. None of the above
Answer & Explanation
Answer: Option B
11. A function's purpose is to print customer data. Which of the following is the best name for this function?
A. pcd(). It's short for "print customer data" and takes few keystrokes
B. Printcustomerdata(). It states everything the function will do
C. printCustomer(). It states the function's purpose and is easy to read
D.
lastFunction(). It is the final function called in most programs, and this name identifies the function's timing
Answer & Explanation
Answer: Option C
12. The function strcmp("Jose", "JOSE") will return _____
A. - 1
B. 0
C. 1
Answer & Explanation
Answer: Option C
13. A pointer to void can hold pointers to
A. char type
B. int type
C. float type
D. any data type
Answer & Explanation
Answer: Option D
14. Which of the following is the extraction operator?
A. >>
B. <<
C. //
D. /*
E. both (a) and (b)
Answer & Explanation
Answer: Option A
15. The function whose prototype is void getData(Item &thing); receives
A. a pointer to a structure
B. a reference to a structure
C. a copy of a structure
D. nothing
Answer & Explanation
Answer: Option B
16. When a multidimensional array is accessed, each array index is
A. separated by commas
B. surrounded by brackets and separated by commas
C. separated by commas and surrounded by brackets
D. surrounded by brackets
Answer & Explanation
Answer: Option D
17. To create a variable, you must assign _____ to it
A. a data type
B. a name
C. both a data type and a name
D. the word var
Answer & Explanation
Answer: Option C
18. You indicate a variable is a pointer variable by placing a(n) _____ in front of the variable's name
A. asterisk
B. ampersand
C. dollar sign
D. exclamation point
Answer & Explanation
Answer: Option A
19. A function can make_________
A. one throw
B. one throw of each scalar type
C. one throw of each programmer-defined type
D. as many throws of as many types as necessary
Answer & Explanation
Answer: Option D
20. A default exception block must be placed _____
A. first among the catch blocks
B. last among the catch blocks
C. globally, at the top of the file
D. at the end of all code in the program
Answer & Explanation
Answer: Option B
21. Which of the following control structures is used in every program?
A. repetition B. selection
C. sequence D. switching
Answer & Explanation
Answer: Option C
22. In the C language, a string is assigned to the
A. char type of variable
B. string type of variable
C. conversion specification %s
D. All of the above
Answer & Explanation
Answer: Option A
23. Which of the following statements declares a one-dimensional Character array named item that consists of five elements?
A. char item[0 to 4] = "";
B. char item[0 to 5] = "";
C. char item[4] = "";
D. char item[5] = "";
E. string item[5] = ' ';
Answer & Explanation
Answer: Option D
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
24. A derived class may also be called a
A. subclass
B. super class
C. parent class
D. derived class
Answer & Explanation
Answer: Option A
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
25. The main() function is always
A. a called function
B. a calling function
C. recursive function
D. used at the end of the program
E. None of the above
Answer & Explanation
Answer: Option B
26. Variables that are known only to the function in which they are declared are called _____ variables
A. global
B. local
C. main
D. separate
E. void Answer & Explanation
Answer: Option B
27. In the expression p --> val,p is a(n)
A. address
B. pointer
C. structure
D. header
Answer & Explanation
Answer: Option B
28. In a template function, _____ argument is generic, or parameterized
A. no
B. exactly one
C. at least one
D. more than one
Answer & Explanation
Answer: Option C
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
29. Object-oriented programmers primarily focus on _________
A. procedures to be performed
B. the step-by-step statements needed to solve a problem
C. objects and the tasks that must be performed with those objects
D. the physical orientation of objects within a program
Answer & Explanation
Answer: Option C
30. You define a structure type globally because
A.
you save many lines of code by not rewriting an identical structure definition in each function that uses it
B. you will never change its definition
C. it is required in C++
D. all of the above
Answer & Explanation
Answer: Option A
31. The standard output stream, which refers to the computer screen, is called
A. cin
B. cout
C. stin
D. stout
E. None of the above
Answer & Explanation
Answer: Option B
32. Which of the following operators is the equality operator?
A. != B. =
C. == D. ->>
E. <> Answer & Explanation
Answer: Option C
33. In C++, you use _____ to perform standard input and output operations
A. characters
B. sequences
C. streams
D. tests
Answer & Explanation
Answer: Option C
34. Values that are used to end loops are referred to as _____ values
A. end
B. finish
C. sentinel
D. stop
Answer & Explanation
Answer: Option C
35. Which of the following flowchart symbols represents the if selection structure?
A. diamond
B. hexagon
C. oval
D. parallelogram
E. rectangle Answer & Explanation
Answer: Option A
36. Two or more arrays whose elements are related by their position (subscript) in the arrays are called _____ arrays
A. horizontal
B. paired
C. parallel
D. related
E. vertical Answer & Explanation
Answer: Option C
37. Assume that a program creates and initializes a Short Integer variable named age and a pointer named agePtr, to which it assigns the address of the age variable. Which of the following statements will assign the number 21 to the age variable?
A. age = 21;
B. *age = 21;
C. agePtr = 21;
D. *agePtr = 21;
E. both (a) and (d)
Answer & Explanation
Answer: Option E
38. The statement fwrite ( (char*)&objl, sizeof(objl) );
A. writes the member functions of objl to fl
B. writes the data in objl to fl
C. writes the member functions and me data of obj 1 to fl
D. writes the address of objl to fl
Answer & Explanation
Answer: Option B
39. The body of a C++ function is surrounded by _____
A. parentheses
B. angle brackets
C. curly brackets
D. square brackets
Answer & Explanation
Answer: Option C
40. Which of the following type casts will convert an Integer variable named amount to a Double type?
A. (double) amount
B. (int to double) amount
C. int to double(amount)
D. int (amount) to double
Answer & Explanation
Answer: Option A
41. The loosest type of coupling is
A. data coupling
B. control coupling
C. external coupling
D. pathological coupling
Answer & Explanation
Answer: Option A
42. Which of the following is a string literal constant?
A. "Visual C++"
B. "137.45"
C. "A"
D. "2,365"
E. All of the above
Answer & Explanation
Answer: Option E
43. Which of the following, if any, are valid names for variables?
A. class
B. friend
C. #OnHand
D. void
E. None of the above are valid names for variables
Answer & Explanation
Answer: Option E
44. A child class _____ exist if there is no parent class
A. must B. may
C. cannot D. can
Answer & Explanation
Answer: Option C
Subscribe to:
Posts (Atom)
No comments:
Post a Comment