Computer Science - Object Oriented Programming Using C++ MCQs Part 5
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
True
B.
False
False
Answer Option A
2. The get() function returns _____
A.
a character
a character
B.
void
void
C.
a reference to the object that invoked it
a reference to the object that invoked it
D.
a copy of the object that invoked it
a copy of the object that invoked it
Answer Option C
3. The most efficient data type for a variable that the number 20000 is the _____ data type
A.
Character
Character
B.
Double
Double
C.
Float
Float
D.
Long Integer
Long Integer
E.
Short Integer
Short Integer
Answer Option E
4. The number 5.5e3 is a _____ constant
A.
character literal
character literal
B.
named literal
named literal
C.
numeric literal
numeric literal
D.
string literal
string literal
Answer Option C
5. The compiler determines the type used in a template function via ___________
A.
the name of the function
the name of the function
B.
the first variable declared within the function
the first variable declared within the function
C.
the type of the argument passed to the function
the type of the argument passed to the function
D.
the type of the value returned from the function
the type of the value returned from the function
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 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 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 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 Option C
10. Static variables are sometimes called
A. class variables
B. functional variables
C. dynamic variables
D. auto variables
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 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 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 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 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 Option C
16. The number 125.35 is a _____
A. character literal constant
B. numeric literal constant
C. string literal constant
D. variable
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 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 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 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 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 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 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 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 Option D
25. An exception specification begins with the keyword _____
A. exception
B. try
C. throw
D. catch
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 Option C
27. It is sometimes useful to specify a class from which no objects will ever be created
A. True
B. False
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 Option D
29. The complement operator is represented by the symbol
A. ~
B. ^
C. i
D. <
E. None of the above
Answer Option A
30. One of the relational operators in the C language is
A. !=
B. &&
C. !
D. #
E. None of the above
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 Option D
32. The rules to any programming language are its _______
A. syntax
B. interpretation
C. logic
D. customs
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 Option B
34. The last statement in a value-returning function is always _____
A. };
B. result expression;
C. return;
D. return expression;
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 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 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 Option D
38. The #include instruction is called a
A. direction
B. directive
C. merge instruction
D. statement.
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 Option A
40. Classes hold _____
A. data
B. methods
C. both data and methods
D. neither data nor methods
Answer Option C
41. In C++, the address operator is the following symbol _____
A. >>
B. &
C. *
D. !
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 Option C
43. The function that takes arguments to set the bits of cout is _____
A. setf()
B. bitset()
C. ios()
D. flat()
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 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 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 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 Option C
Comments
Post a Comment