Computer Science - Object Oriented Programming Using C++ MCQs Part 1
1. You can use C++ as a procedural, as well as an object-oriented, language
A.
True
True
B.
False
False
Answer Option A
2. A default catch block catches
A.
all thrown objects
all thrown objects
B.
no thrown objects
no thrown objects
C.
any thrown object that has not been caught by an earlier catch block
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
all thrown objects that have been caught by an earlier catch block
Answer Option C
3. Adding a derived class to a base class requires fundamental changes to the base class
A.
True
True
B.
False
False
Answer Option B
4. Format flags may be combined using
A.
the bitwise OR operator (|)
the bitwise OR operator (|)
B.
the logical OR operator (||)
the logical OR operator (||)
C.
the bitwise AND operator (&)
the bitwise AND operator (&)
D.
the logical AND operator (&&)
the logical AND operator (&&)
Answer Option A
5. The use of the break statement in a switch statement is
A.
optional
optional
B.
compulsory
compulsory
C.
not allowed. It gives an error message
not allowed. It gives an error message
D.
to check an error
to check an error
E.
None of the above
None of the above
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 Option C
7. Evaluate the following expression: 3 >6&&7>4
A. True
B. False
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 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 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 Option B
11. When the compiler cannot differentiate between two overloaded constructors, they are called
A. overloaded
B. destructed
C. ambiguous
D. dubious
Answer Option C
12. Some Streams work with input, and some with output
A. True
B. False
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 Option C
14. Which type of statement does not occur in computer programs?
A. sequence
B. loop
C. denial
D. selection
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 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 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 Option B
18. The keyword used to define a structure is _____
A. stru
B. stt
C. struct
D. structure
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 Option C
20. Header files often have the file extension _____
A. .H
B. .HE
C. .HEA
D. .HEAD
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 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 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 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 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 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 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 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 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 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 Option B
31. The best form of coupling is _____
A. complete
B. tight
C. loose
D. free
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 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 Option D
34. An array name is a _____
A. subscript
B. formal parameter
C. memory address
D. prototype
Answer Option C
35. To enter a comment in a C++ program, you begin the comment with _____
A. **
B. &&
C. \\
D. @
E. //
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 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 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 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 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 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 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 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 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 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 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 Option B
47. A base class may also be called a
A. child class
B. subclass
C. derived class
D. parent class
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 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 Option A
Comments
Post a Comment