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

1. The comma operator (,) is primarily used in conjunction with

A.
'for' statement
B.
'if-else' statement
C.
'do-while' statement
D.
All of the above
E.
None of the above

 Answer Option A

2. To execute a C++ program, you first need to translate the source code into object code. This process is called

A.
coding
B.
compiling
C.
sourcing
D.
translating

 Answer Option B

3. The rules of a programming language are called its _____

A.
code
B.
guidelines
C.
procedures
D.
regulations
E.
syntax

 Answer Option E

4. An array element is accessed using

A.
a first-in-first-out approach
B.
the dot operator
C.
a member name
D.
an index number

 Answer Option D

5. The program can access the private members of a class

A.
directly
B.
only through other private members of the class
C.
only through other public members of the class
D.
None of the above - the program cannot access the private members of a class in any way

 Answer Option C

6. To hide a data member from the program, you must declare the data member in the _____ section of the class

A. concealed
B. confidential
C. hidden
D. private
E. restricted

 Answer Option D

7. External documentation includes

A. a printout of the program's code
B. flowcharts
C. IPO charts
D. pseudocode
E. All of the above

 Answer Option A

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

9. A variable's _____ indicates how long the variable remains in the computer's memory

A. area
B. extent
C. lifetime
D. reach
E. scope

 Answer Option C

10. The function whose prototype is void getData(Item *thing); receives

A. a pointer to a structure
B. a reference to a structure
C. a copy of a structure
D. nothing

 Answer Option A

11. You may override the class access specifier for_____

A. public members
B. public and protected members
C. any specific class members you choose
D. no clas smembers

 Answer Option C

12. The null character needs a space of

A. zero bytes
B. one byte
C. three bytes
D. four bytes
E. None of the above

 Answer Option B

13. The number of structures than can be declared in a single statement is

A. one
B. two
C. three
D. unlimited

 Answer Option D

14. The cout << sales[0] + sales[1]; statement will______

A. display 22000
B. display 10000 + 12000
C. display sales[0] + sales[l]
D. result in an error

 Answer Option A

15. The most efficient data type for a variable that stores the letter C is the _____ data type

A. Character
B. Double
C. Float
D. Long Integer
E. Short Integer

 Answer Option A

16. The C++ operator used to allocate memory is _________

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

 Answer Option C

17. Assume that your version of C++ can recognize only the first 8 characters of an identifier name, through identifier names may be arbitrarily long. Which of the following identifier names is not distinct:

A. list, list2
B. address, Address
C. identifier_l, identifier_2
D. answer, ANSWER
E. None of the above

 Answer Option C

18. Object is to class as _____

A. library is to book
B. mother is to daughter
C. Plato is to philosopher
D. president is to Lincoln

 Answer Option C

19. A derived class may also be called a

A. subclass
B. super class
C. parent class
D. base class

 Answer Option A

20. The C++ keyword for declaring a variable that contains a decimal point is _____

A. dec
B. decimal
C. float
D. floater
E. None of the above

 Answer Option C

21. When you define an object that is a member of a class, such as Student Abby; _____

A. a block of memory is set aside and all data members are assigned valid values
B. a block of memory is set aside
C. no memory is set aside until values are defined
D. no memory is set aside, but valid values are assigned to data members

 Answer Option B

22. A program can directly access the _____ members of a class

A. hidden
B. private
C. public
D. both (b) and (c)

 Answer Option C

23. Any output manipulator function you create _____

A. should take as an argument an instance of ostream as a reference
B. should return void
C. must be a member function of the ostream class
D. must inherit ostream

 Answer Option A

24. To pass an array by reference, you

A. must include the address-of (&) operator before the array's name
B. must include the number symbol (#) before the array's name
C. do not have to do anything because arrays are automatically passed by reference

 Answer Option C

25. The instructions you enter into the computer are called the _____

A. edited code
B. machine code
C. object code
D. source code

 Answer Option D

26. The String data type is an extension of the _____ data type

A. Character
B. Double
C. Letter
D. Long
E. Text

 Answer Option A

27. An advantage of using local variables is that _____

A. they are known to all functions in the file
B. names used in one function do not affect data stored in variables with the same names in other functions
C. values given to local variables are retained when those parameters go out of scope
D. the program does not become "crowded" with too many variable names

 Answer Option D

28. The difference between a return and a throw is that _____

A. with a throw, no value can be sent
B. with a return, no value can be sent
C. with a throw, execution takes place at the location from which the function was called
D. with a return, execution takes place at the location from which the function was called

 Answer Option D

29. Which is a good reason for passing a variable's address to a function?

A. the function will have a copy of the variable
B. the function cannot change the value of the variable in the calling function
C. C++ requires that all variables used in a function be passed by address
D. the function needs to change multiple variable values
E. the called function can change the value of the variable in the calling function

 Answer Option E

30. The string HELLO WORLD needs

A. 11 bytes
B. 12 bytes
C. 10 Bytes
D. 8 bytes
E. None of the above

 Answer Option A

31. Library header files usually contain

A. complete functions
B. parts of functions
C. function prototypes for functions stored in other files
D. function bodies, but not function headers

 Answer Option C

32. A C++ term meaning "generic" is

A. argument
B. parameterized
C. universal
D. global

 Answer Option B

33. Before object-oriented exception handling was practiced, _____

A. no run-time errors occurred
B. programmers could not deal with run-time errors
C. the most popular error-handling method was to terminate the program
D. the most popular error-handling method was to throw an exception

 Answer Option C

34. The preprocessor directive always ends with

A. a comma
B. a semicolon
C. neither a semicolon nor a comma
D. "/"
E. None of the above

 Answer Option C

35. A constructor initialization list produces similar results to

A. overriding
B. assignment
C. redeclaring
D. output

 Answer Option B

36. Which of the following stream manipulators advances the cursor to the next line on the computer screen?

A. adin
B. advin
C. edlin
D. endl
E. lineadv

 Answer Option D

37. 6.5 is a _____ constant

A. character literal
B. named literal
C. numeric literal
D. string literal

 Answer Option C

38. The time and memory involved in calling a function represent the function's _____

A. prototype
B. overhead
C. cost
D. burden

 Answer Option B

39. Which function is most likely to have procedural cohesion?

A. main()
B. findSquareRoot()
C. getSaleSubtractDiscountAddTax()
D. openFiles()

 Answer Option A

40. A pointer is

A. the address of a variable
B. an indication of the variable to be accessed next
C. a variable for storing addresses
D. the data type of an address variable

 Answer Option C

41. The instruction "If it's raining outside, then take an umbrella to work" is an example of the _____ structure

A. control
B. repetition
C. selection
D. sequence
E. switching

 Answer Option C

42. Which of the following statements will assign the address of the age variable to the agePtr pointer?

A. agePtr = &age;
B. agePtr = *age;
C. &agePtr = age;
D. *agePtr = age;
E. agePtr -> *age;

 Answer Option A

43. The >> (extraction) operator stops reading characters from the keyboard as soon as the user _____

A. presses the Enter key
B. types a character that is inappropriate for the variable's data type
C. both (a) and (b)

 Answer Option C

44. In the statement template,

A. T is a class
B. T is a scalar variable
C. either (a) or (b)
D. neither (a) nor (b)

 Answer Option C

45. The null character is represented by

A. \n
B. \0
C. \o
D. \r
E. None of the above

 Answer Option B

46. The break statement is

A. a preprocessor directive
B. an operator in the C++ language
C. a keyword in the C++ language
D. switch in the C++ language
E. None of the above

 Answer Option C

47. A variable w with a value 67 may be defined with _______

A. int w = 67;
B. int w(67);
C. int 67(w);
D. both (a) and (b), but not (c).

 Answer Option D

48. An expression contains relational, assignment and arithmetic operators. In the absence of parentheses, the order of evaluation will be

A. assignment, relational, arithmetic
B. arithmetic, relational, assignment
C. relational, arithmetic, assignment
D. assignment, arithmetic, relational
E. None of the above

 Answer Option B

49. The keyword virtual indicates that

A. a derived class has public access to a base class
B. more than one base class exists
C. a base class should be used only once in inheritance
D. a derived class should have more than one base class constructed

 Answer Option C

50. If you declare two objects as Customer firstCust, secondCust; which of the following must be true?

A. Each object will store a separate copy of any static member data
B. Each object will store a separate copy of any member functions
C. Each object will store a separate copy of any nonstatic data members
D. You cannot declare two objects of the same class

 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