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

1. When you omit parameters from a function call, values can be provided by

A.
formal parameters
B.
reference parameters
C.
overloaded parameters
D.
default parameters

 Answer Option D

2. The first element in a string is

A.
the name of the string
B.
the first character in the string
C.
the length of the string
D.
the name of the array holding the string

 Answer Option B

3. Variables declared outside a block are called _____

A.
global
B.
universal
C.
stellar
D.
external

 Answer Option A

4. The compiler converts your C++ instructions into _____

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

 Answer Option B

5. A fundamental type such as int or double is a _____

A.
programmer-defined type
B.
complex type
C.
nonscalar type
D.
scalar type

 Answer Option D

6. The return type you code for all constructors is _____

A. void
B. the class type
C. the same type as the first data member defined in the class
D. no type

 Answer Option D

7. When an object-oriented program detects an error within a function, the function _________

A. throws an exception
B. throws a fit
C. catches a message
D. catches an exception

 Answer Option A

8. Using a statement at the wrong time or with an inappropriate object creates a

A. logical error
B. syntax error
C. compiler error
D. language error

 Answer Option A

9. When you create a derived class and instantiate an 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

10. Evaluate the following expression: 4 >6 || 10 < 2 * 6

A. True
B. False

 Answer Option A

11. A constructor always has

A. communicational cohesion
B. temporal cohesion
C. logical cohesion
D. no cohesion

 Answer Option B

12. A normal C++ operator that acts in special ways on newly defined data types is said to be

A. glorified
B. encapsulated
C. classified
D. overloaded

 Answer Option D

13. A function in a derived class that has the same name as a function in the parent class

A. will override the base class function
B. will cause an error message to display
C. will be overridden by the base class function
D. will execute immediately often the base class function executes

 Answer Option A

14. In which statements, does a 'continue' statements cause the control to go directly to the test condition and then continue the looping process?

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

 Answer Option D

15. Which of the following statements is false?

A. You typically use a public member function to change the value in a private data member
B. Because the constructor function does not return a value, you place the keyword void before the constructor's name
C. The public member functions in a class can be accessed by any program that uses an object created from that class
D. An instance of a class is considered an object

 Answer Option B

16. In a class specifier, data or functions designated private are accessible

A. to any function in the program
B. only if you know the password
C. to member functions of that class
D. only to public members of the class

 Answer Option C

17. When a function includes a throw statement for errors, the call to the potentially offending function should be placed within a _____ block

A. throw
B. try
C. catch
D. scope

 Answer Option B

18. The scope resolution operator is

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

 Answer Option D

19. "C++" is a _____ constant

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

 Answer Option D

20. In a C++ program, which of the following can be thrown?

A. scalar variables
B. programmer-defined objects
C. both (a) and (b)
D. neither (a) nor (b)

 Answer Option B

21. The items listed in the function header are called _____

A. actual arguments
B. formal parameters
C. passed parameters
D. sent arguments

 Answer Option B

22. A translator that notes whether you have used a language correctly may be called a _____

A. theasurus
B. compiler
C. coder
D. decoder

 Answer Option B

23. The feature in object-oriented programming that allows the same operation to be carried out differently, depending on the object, is_____

A. inheritance
B. polymorphism
C. overfunctioning
D. overriding

 Answer Option B

24. When an argument is passed by reference,

A. a variable is created in the function to hold the argument's value
B. the function cannot access the argument's value
C. a temporary variable is created in the calling program to hold the argument's value
D. the function accesses the argument's original value in the calling program
E. None of the above

 Answer Option D

25. The process of extracting the relevant attributes of an object is known as

A. polymorphism
B. inheritance
C. abstraction
D. data hiding

 Answer Option C

26. Which of the following statements uses the computer's clock to initialize the random number generator?

A. srand(time);
B. srand(time(NULL));
C. time(srand);
D. time(srand(NULL));

 Answer Option B

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

28. You must provide a constructor for a derived class

A. always
B. if the base class constructor required arguments
C. if the base class constructor does not required arguments
D. never

 Answer Option B

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

30. To use one of the C++ built-in mathematical functions, you must include the _____ header file in your program

A. calculation.h
B. compute.h
C. expression.h
D. math.h
E. mathematical.h

 Answer Option D

31. Errors in a program are called

A. accidents
B. annoyances
C. bugs
D. mistakes
E. typing errors

 Answer Option C

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

A. Each object's nonstatic data members will be stored in the same memory location
B. Each object will be stored in the same memory location
C. Each object will have a unique memory address
D. You cannot declare two objects of the same class

 Answer Option C

33. Which of the following is the inequality operator?

A. !=
B. =
C. ==
D. -->
E. <>

 Answer Option A

34. If a derived class uses the public access specifier, then _____

A. public base class members remain public in the derived class
B. protected base class members become public in the derived class
C. both (a) and (b)
D. neither (a) nor (b)

 Answer Option A

35. The operator that releases previously allocated memory is _____

A. release
B. return
C. delete
D. destroy

 Answer Option C

36. When a language has the capability to produce new data types, it is said to be

A. reprehensible
B. encapsulated
C. overloaded
D. extensible

 Answer Option D

37. A compound statement does not consist of

A. a single statement
B. other compound statements
C. expression statements
D. control statements
E. None of the above

 Answer Option A

38. Which of the following statements will display the word "Hello" on the computer screen?

A. cin << "Hello";
B. cin >> "Hello";
C. cout << "Hello";
D. cout >> "Hello";
E. None of the above

 Answer Option C

39. The preprocessor directive always starts with the symbol

A. %
B. &
C. #
D. ""
E. None of the above

 Answer Option C

40. Which of the following statements is true?

A. Data coupling is tighter than pathological coupling
B. Common coupling is looser than data coupling
C. Data-structured coupling is looser than control coupling
D. Control coupling is looser than data coupling

 Answer Option C

41. Evaluate the following expression: 7 >=3 + 4 || 6<4 && 2<5

A. True
B. False

 Answer Option A

42. The base class for most stream classes is the _____ class

A. ios
B. out
C. in
D. app

 Answer Option A

43. Which of the following while clause will stop the loop when the value in the age variable is less than the number 0?

A. while age < 0
B. while (age < 0)
C. while age >= 0;
D. while (age >= 0);
E. while (age >= 0)

 Answer Option E

44. The most efficient data type for a variable that stores the number 4.6e20 is the _____ data type

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

 Answer Option C

45. Which of the following is a C++ object?

A. cin
B. >>
C. iostream
D. read()

 Answer Option A

46. Which of the following can be used to declare the main function?

A. void main
B. void Main()
C. void main()
D. main
E. either (b) or (c) can be used

 Answer Option C

47. You _____ write your own container classes

A. must
B. may
C. should not
D. must not

 Answer Option B

48. If an integer 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. int
B. double
C. either (a) or (b)
D. neither (a) nor (b)

 Answer Option A

49. The highest level of cohesion is

A. functional cohesion
B. temporal cohesion
C. logical cohesion
D. sequential cohesion

 Answer Option A

50. You separate a derived class name from its access specifier with

A. a colon
B. two colons
C. at least one space
D. a semicolon

 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