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

1. Programmer-defined functions can be

A.
value-returning functions only
B.
void functions only
C.
either value-returning or void functions

 Answer Option C

2. A class D can be derived from a class C, which is derived from a class B, which is derived from a class A

A.
True
B.
False

 Answer Option A

3. To use the strcpy function, you must include the _____ header file in your program

A.
assign.h
B.
copy.h
C.
string.h
D.
strcopy.h
E.
strcpy.h

 Answer Option C

4. The number of the relational operators in the C language is

A.
four
B.
six
C.
three
D.
one
E.
None of the above

 Answer Option B

5. Which of the following tells C++ to display numbers with two decimal places?

A.
setdecimal(2)
B.
setiosflags(2)
C.
setiosflags(2.00)
D.
setprecision(2)

 Answer Option D

6. 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

7. We can output text to an object of class ofstream using the insertion operator ├é« because

A. the ofstream class is a stream
B. the insertion operator works with all classes
C. we are actually outputting to cout
D. the insertion operator is overloaded in ofstream

 Answer Option D

8. The operator that allocates new memory is _____

A. allocate
B. mem
C. new
D. next

 Answer Option C

9. A comment

A. is a note that can be put into the source code
B. is ignored by the compiler.
C. starts with the /* character pair
D. All of the above
E. None of the above

 Answer Option D

10. Which of the following is(are) valid identifier(s)?

A. record_1
B. 1 record
C. return
D. $tax
E. None of the above

 Answer Option A

11. The functions go in the _____ section of a class definition

A. declaration
B. implementation
C. prototype
D. functioning

 Answer Option B

12. You can throw _____

A. a scalar variable
B. a constant
C. a programmer-defined class object
D. any of these

 Answer Option D

13. You invoke a function with a function

A. call
B. declaration
C. definition
D. prototype

 Answer Option A

14. Which is a good guideline for creating function names?

A. Use all lowercase letters to identify the functions as C++ functions
B. Use long names to reduce the likelihood of creating a duplicate function name
C. Use abbreviations as much as possible to save both keystrokes and memory
D. Avoid the use of digits because they are easily confused with letters

 Answer Option D

15. Reserving memory during program execution is known as reserving it

A. dynamically
B. statically
C. functionally
D. powerfully

 Answer Option A

16. "Rohan Motors" is a _____

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

 Answer Option C

17. A programming structure that contains data and a pointer to the next object is a

A. template
B. class
C. pointer class
D. linked list

 Answer Option D

18. A variable declared in a function is called a(n) _____ variable

A. area
B. global
C. local
D. reference
E. value

 Answer Option C

19. When you write to a file rather than the screen, you use the C++ class _____

A. iostream
B. filed
C. fstream
D. diskclass

 Answer Option C

20. Which of the following numerical value(s) is(are) invalid constant(s)?

A. 0.7
B. 9.3el2
C. 27,512
D. 12345678
E. None of the above

 Answer Option C

21. To use the this pointer with a member function, you _____

A. declare this as static
B. declare this as global
C. define this as equal to the address of the appropriate object
D. do nothing; it is automatically supplied for you

 Answer Option D

22. A function that is prototype as int calculate(int num); may

A. receive an integer variable named num from the main() program
B. receive any integer variable from the main() program
C. either (a) or (b)
D. neither (a) nor (b)

 Answer Option C

23. A do-while loop contains

A. only one statement between the do statement and the while statement
B. several statements between the do statement and the while statement
C. no statement at all between the do statement and the while statement
D. only two statement between the do statement and the while statement
E. None of the above

 Answer Option B

24. The braces that surround the code in a 'C program

A. show what code goes in a particular function
B. delimit a section of code
C. separate the codes from the constant
D. separate the source file from the subject file
E. None of the above

 Answer Option B

25. The indirection operator is the

A. asterisk
B. ampersand
C. dollar sign
D. plus sign

 Answer Option A

26. Local variables _____

A. are created outside a block
B. are known only to that block
C. continue to exist when their block ends
D. are illegal in C++

 Answer Option B

27. # directives must be present

A. before the main() function
B. after the main() function
C. at the end of the program
D. anywhere in the program body
E. None of the above

 Answer Option A

28. Programmers prefer to declare almost all variables _____

A. at the beginning of each function
B. globally
C. on one line
D. with cryptic names

 Answer Option A

29. A(n) _____ is always incremented by a constant amount, whereas a(n) _____ is incremented by an amount that varies

A. accumulator, counter
B. counter, accumulator

 Answer Option B

30. The C++ _____ function generates random numbers

A. generate()
B. genRand
C. rand
D. randGen
E. srand

 Answer Option E

31. You have declared an integer pointer called point You have also declared an integer called number. Which statement is the correct format?

A. point = number;
B. point = *number;
C. point = &number;
D. point = +number;

 Answer Option C

32. If you wanted to sort many large objects or structures, it would be most efficient to

A. place them in an array and sort the array
B. place pointers to them in an array and sort the array
C. place them in a linked list and sort the linked list
D. place references to them in an array and sort the array

 Answer Option B

33. A function that is prototyped as double calculate(int num); may ______

A. receive a double constant such as 3.9
B. receive a double variable
C. either (a) or (b)
D. neither (a) nor (b)

 Answer Option D

34. The printer can be accessed using the predefined filename _____

A. printer file
B. print
C. cout
D. PRN, LPT1, etc

 Answer Option D

35. The best functions have _____

A. high cohesion and tight coupling
B. high cohesion and loose coupling
C. low cohesion and tight coupling
D. low cohesion and loose coupling

 Answer Option B

36. One of the valid escape sequences used in the C language is

A. \z
B. \N
C. \t
D. \s
E. None of the above

 Answer Option C

37. 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

38. Which of the following will increase the value stored in the first element of the fee array by 2?

A. amount[0] = amount[0] + 2;
B. amount, fee[0] = amount, fee [0] + 2;
C. feelnfo.amount[0] = feelnfo.amount[0] + 2;
D. fee[0].amount = fee[0].amount + 2;
E. fee.amount[0] = fee.amount[0] + 2;

 Answer Option D

39. Which loop always processes its instructions at least once?

A. do-while
B. for
C. while

 Answer Option A

40. When a new class is derived from an existing class, the derived class member functions _____ have names that differ from base class function names

A. may
B. may if the two classes have the same name
C. must
D. must not

 Answer Option A

41. A static data member is given a value

A. within the class definition
B. outside the class definition
C. when the program is executed
D. never

 Answer Option B

42. _____ refers to the process of locating and removing the errors in a program

A. Analyzing
B. Correcting
C. Debugging
D. Executing
E. Tracking

 Answer Option C

43. Static variables are sometimes called

A. class variables
B. functional variables
C. dynamic variables
D. auto variables

 Answer Option A

44. You can pass _____ to functions

A. copies of individual structure members
B. copies of entire structures
C. pointers to structures
D. All of the above

 Answer Option D

45. Element doubleArray[7] is which element of the array?

A. the sixth
B. the seventh
C. the eighth
D. impossible to tell

 Answer Option C

46. Which of the following statements opens a file named temp.dat for output?

A. outFile.open("temp .dat");
B. fileOut.output("temp .dat");
C. openFile.out("temp .dat");
D. fileOpen.out("temp .dat");
E. out.fileOpen("temp .dat");

 Answer Option A

47. Which of the following will store the letter H in a Character variable named initial?

A. initial = 'H'
B. initial = 'H';
C. initial = "H"
D. initial = "H";

 Answer Option B

48. Compared with the classes from which they are derived, inherited classes may have _____

A. additional data members
B. additional member functions
C. both (a) and (b)
D. neither (a) nor (b)

 Answer Option C

49. 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

50. To write data that contains variables of type float, to an object of type ofstream, you should use

A. the insertion operator
B. seekg()
C. writeQ
D. put()

 Answer Option C

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