Computer Science - Object Oriented Programming Using C++ MCQs Part 8

1. Variables that are declared in a block are known as _____ variables to that block

A.
confined
B.
local
C.
global
D.
immediate

 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 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 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 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 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 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 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 Option C

9. Which of the following are void functions?

A. main
B. pow
C. sqrt
D. All of the above

 Answer Option A

10. Hiding individual components of an entry is _____

A. polymorphism
B. encapsulation
C. scaling
D. not recommended in C++

 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 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 Option B

13. Having more than one function with the same name is called

A. overloading
B. defaulting
C. casting
D. referencing

 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 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 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 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 Option A

18. Which of the following is an access specifier?

A. particular
B. shielded
C. protected
D. safe

 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 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 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 Option D

22. A pattern for creating an object is called a(n) _____

A. class
B. attributes
C. private
D. public

 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 Option B

24. An object is a(n) _____ of a class

A. owner
B. function
C. definition
D. instance

 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 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 Option C

27. The function printDataMembers() is mot likely a(n) ________

A. inspector functions
B. mutator functions
C. auxiliary functions
D. manager functions

 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 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 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 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 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 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 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 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 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 Option E

37. A measure of the strength of the connection between two functions is

A. cohesion
B. coupling
C. dependence
D. subjection

 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 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 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 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 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 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 Option D

44. Access specifiers are followed by

A. a comma
B. a semicolon
C. a colon
D. two colons

 Answer Option C

45. Elements in an array are identified by a unique _____

A. data type
B. order
C. subscript
D. symbol

 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 Option C

47. A C++ statement must end in a

A. : (column)
B. , (comma)
C. . (period)
D. ; (semicolon)

 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 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 Option B

Comments

Most Popular

PhpStorm, return value is expected to be 'A', 'object' returned

Remove Unicode Zero Width Space PHP

Laravel file upload returns forbidden 403, file permission is 700 not 755