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

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

3. The weakest form of cohesion is

A.
coincidental
B.
functional
C.
logical
D.
communicational

 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 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 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<
B. cout<<*Value;
C. cout<<&P;
D. cout<<*P;

 Answer Option D

7. A constructor initialization list is preceded by

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

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

10. Which of the following is the scope resolution operator?

A. ->>
B. ::
C. *
D. &

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

18. Variables that hold memory addresses are called _____

A. subscripts
B. holders
C. pointers
D. indicators

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

23. The extraction operator >> is a(n) _____

A. overloaded function
B. C++ class
C. C++ object
D. static reference variables

 Answer Option A

24. Modules in C++ programs are

A. functions
B. procedures
C. subroutines
D. miniprograms

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

30. Which functions do not have a this pointer?

A. access functions
B. inspector functions
C. member functions
D. static functions

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

35. In object-oriented terms, an exception may be considered a(n) _____

A. child
B. encapsulation
C. message
D. scalar type

 Answer Option C

36. A(n) _____ is a numeric variable used for counting something

A. accumulator
B. adder
C. constant
D. counter
E. integer

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

48. The letter V is a _____

A. character literal constant
B. numeric literal constant
C. string literal constant
D. variable

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

Comments

Most Popular

Remove Unicode Zero Width Space PHP

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

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