Computer Science - Object Oriented Programming Using C++ MCQs Part 6
1. Which of the following are valid characters for a numeric literal constant?
A.
a decimal point
a decimal point
B.
the letter e
the letter e
C.
a minus sign
a minus sign
D.
a plus sign
a plus sign
E.
All of the above
All of the above
Answer Option E
2. Any #include files may contain
A.
constants
constants
B.
variables
variables
C.
functions
functions
D.
All of the above
All of the above
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
to the last lines in the program
B.
to the next statement written after the body of the loop
to the next statement written after the body of the loop
C.
to the first statement in the body of the loop
to the first statement in the body of the loop
D.
All. of the above
All. of the above
E.
None of the above
None of the above
Answer Option B
4. The function that takes arguments to set the bits of count is _____
A.
setf()
setf()
B.
bitsef()
bitsef()
C.
ios()
ios()
D.
flag()
flag()
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
must also be named T
B.
must be named U
must be named U
C.
can be any legal C++ identfier
can be any legal C++ identfier
D.
it is illegal to have two types
it is illegal to have two types
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 Option D
7. Making class members inaccessible to nonmember functions is an example of
A. polymorphism
B. data hiding
C. redundancy
D. recursion
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 Option A
9. 3 is a _____ constant
A. character literal
B. named literal
C. numeric literal
D. string literal
Answer Option C
10. _____ variables remain in memory until the statement block ends
A. Area
B. Global
C. Local
D. Reference
E. Value
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 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 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 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 Option C
15. The extraction operator >> is a(n)
A. overloaded function
B. C++ class
C. C++ object
D. static reference variable
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 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 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 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 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
B. #include iostream.h
C. #include
D. #merge iostream.h
E. None of the above
Answer Option E
21. The statement double total = 0.0; performs _____
A. assignment
B. initialization
C. rationalization
D. polymorphism
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 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 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 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 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 Option B
27. The function stricmp("Jose", "JOSE") will return _____
A. - 1
B. 0
C. 1
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 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 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 Option B
31. The _____ function returns the uppercase equivalent of a character
A. caseupper
B. charupper
C. toupper
D. uCase
E. upper
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 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 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 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 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 Option D
37. When the compiler cannot differentiate between two overloaded constructors, they are called______
A. overloaded
B. destructed
C. ambiguous
D. dubious
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 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 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 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 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 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 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 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 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 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 Option D
48. The right shift operator is represented by the symbol
A. >
B. >>
C. ->
D. <
E. None of the above
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 Option B
Comments
Post a Comment