Quiznetik

Object Oriented Programming with C++ (OOP in C++) | Set 2

1. A private member function can be called by another function that is a member of a class is called

Correct : B. Nesting of member function

2. The function that is a bridge between two classes

Correct : A. Friend function

3. The break statement causes an exit

Correct : C. from all loops & switches.

4. The arrays of variable that are of the type class

Correct : A. Array of object

5. Which of the following is not a type of constructor?

Correct : B. Friend constructor

6. Which of the following statements is incorrect?

Correct : D. Friend keyword can be used on main().

7. Which of the following statement is correct regarding destructor of base class?

Correct : B. Destructor of base class should always be virtual.

8. How can we make a class abstract?

Correct : B. By making at least one member function as pure virtual function.

9. Which of the following statements is correct when a class is inherited publicly?

Correct : D. Public members of the base class become public members of derived class.

10. Which of the following access specifies is used in a class definition by default?

Correct : C. Private

11. Which of the following statement is correct with respect to the use of friend keyword inside a class?

Correct : B. A class may be declared as a friend.

12. Which of the following keywords is used to control access to a class member?

Correct : C. Protected

13. Which of the following type of data member can be shared by all instances of its class?

Correct : C. Static

14. Constructor is executed when _____.

Correct : A. an object is created

15. Which of the following also known as an instance of a class?

Correct : B. Object

16. How many objects can be created from an abstract class?

Correct : A. Zero

17. Which of the following statements is correct?

Correct : B. Both data and functions can be either private or public.

18. Which of the following can be overloaded?

Correct : D. Both B and C

19. Which of the following is the only technical difference between structures and classes in C++?

Correct : C. Member function and data are by default public in structures but private in classes.

20. Which of the following statements are correct for a static member function? 1. It can access only other static members of its class. 2. It can be called using the class name, instead of objects.

Correct : C. Both 1 and 2 are correct.

21. Which of the following means "The use of an object of one class in definition of another class"?

Correct : C. Composition

22. Which of the following statements is correct when a class is inherited publicly?

Correct : D. Public members of the base class become public members of derived class

23. Which of the following statements is correct about the constructors and destructors?

Correct : B. Constructors can take arguments but destructors cannot.

24. Which of the following statement is correct?

Correct : C. Both A and B.

25. Which of the following statement is correct?

Correct : D. A function can be overloaded more than once.

26. Which of the following statement will be correct if the function has three arguments passed to it?

Correct : A. The trailing argument will be the default argument.

27. Which of the following statement is incorrect?

Correct : C. Default argument cannot be provided for pointers to functions.

28. Which of the following statement is correct?

Correct : A. Constructors can have default parameters.

29. Which of the following function / type of function cannot be overloaded?

Correct : C. Virtual function

30. Which of the following statement is incorrect?

Correct : D. The default arguments are given in the function prototype and should be repeated in the function definition.

31. Where the default value of parameter have to be specified?

Correct : C. Function prototype

32. Which of the following statement is correct?

Correct : D. C++ does not allow the redefinition of a default parameter.

33. Which of the following statement is correct?

Correct : C. All the parameters of a function can be default parameters.

34. Which of the following function / types of function cannot have default parameters?

Correct : B. main()

35. A constructor that accepts __________ parameters is called the default constructor.

Correct : C. no

36. What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero‐argument constructor?

Correct : A. Compile‐time error.

37. Destructor has the same name as the constructor and it is preceded by ______ .

Correct : C. ~

38. For automatic objects, constructors and destructors are called each time the objects

Correct : A. enter and leave scope

39. Which constructor function is designed to copy objects of the same class type?

Correct : D. Copy constructor

40. Which of the following statement is correct?

Correct : C. Both A and B.

41. When are the Global objects destroyed?

Correct : B. When the program terminates.

42. Copy constructor must receive its arguments by __________ .

Correct : C. only pass‐by‐reference

43. A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.

Correct : B. destructor

44. Which of the following gets called when an object goes out of scope?

Correct : B. destructor

45. _________ used to make a copy of one class object from another class object of the same class type.

Correct : B. copy constructor

46. Constructors __________ to allow different approaches of object construction.

Correct : B. can be overloaded

47. Which of the following cannot be declared as virtual?

Correct : A. Constructor

48. If the copy constructor receives its arguments by value, the copy constructor would

Correct : C. call itself recursively

49. Which of the following are NOT provided by the compiler by default?

Correct : D. Copy Destructor

50. It is a __________ error to pass arguments to a destructor.

Correct : C. syntax

51. A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.

Correct : A. default constructor

52. How many default constructors per class are possible?

Correct : A. Only one

53. Which of the following statement is correct?

Correct : A. A constructor has the same name as the class in which it is present.

54. A destructor takes __________ arguments.

Correct : D. no

55. Destructor calls are made in which order of the corresponding constructor calls?

Correct : A. Reverse order

56. Which of the following never requires any arguments?

Correct : C. Default constructor

57. A class's __________ is called when an object is destroyed.

Correct : B. destructor

58. How many times a constructor is called in the life‐time of an object?

Correct : A. Only once

59. To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .

Correct : C. delete[]

60. Which of the following statement is correct whenever an object goes out of scope?

Correct : C. The default destructor of the object is called.

61. Which allows you to create a derived class that inherits properties from more than one base class?

Correct : B. Multiple inheritance

62. Which feature in OOP allows reusing code?

Correct : B. Inheritance

63. The mechanism of deriving a new class from another class

Correct : B. Inheritance

64. A derived class with only one base class

Correct : C. Single inheritance

65. The mechanism of deriving one base class with more than one derived classes

Correct : D. Hierarchical Inheritance

66. The duplication of inherited members due to the multiple paths can be avoided by making a common base class is called

Correct : B. Virtual base class

67. The class that is not used to create object

Correct : A. Abstract class

68. The mechanism of giving special meaning to an operator

Correct : A. Operator overloading

69. The operators can’t be overloaded

Correct : C. Ternary operator

70. Which of the following is not correct

Correct : C. We can change the basic meaning of the operator

71. The operator we cannot use friend function

Correct : D. []

72. A friend function for unary operator overloading takes ‐‐‐‐ ‐arguments.

Correct : B. One

73. A member function for unary operator overloading takes‐‐‐‐ ‐arguments.

Correct : A. Zero

74. A friend function for binary operator overloading takes‐‐‐‐ ‐arguments.

Correct : C. Two

75. The variable that contains the address of constant or variable

Correct : C. pointer

76. The indirect operator is

Correct : B. *

77. The memory management operator in c++

Correct : A. new &delete

78. The pointer refers to an object that has called the member function currently

Correct : A. this

79. Conversion of data type is called

Correct : B. type casting

80. The function that act as an interface to base & derived class

Correct : B. virtual function

81. The keyword to convert constant into variable

Correct : A. Const_cast

82. The keyword to convert pointer into non pointer & non pointer into pointer

Correct : B. reinterpret_cast

83. Treating the address of the object of the derived class as the address of the base class means

Correct : A. Up casting

84. The empty virtual function are called

Correct : A. pure /donothing

85. A stream of byte that is the interface between IO and IO devices

Correct : A. Streams

86. The class that derived from standard library ios contain input functions

Correct : C. istream

87. The class that derived from standard library ios contain output functions

Correct : D. ostream

88. Which function is in the ostream class

Correct : C. write

89. Which function is in the istream class

Correct : A. get()

90. The standard library inherited from istream & ostream

Correct : B. iostream

91. The function used to receive one character at a time

Correct : A. get()

92. The function used to disply one character at a time

Correct : B. put()

93. The function used to receive one line at a time

Correct : C. getline()

94. The function used to display one line at a time

Correct : D. write()

95. The function contain in the ios class to set width

Correct : A. width()

96. The function contain in the class iomanip to set width

Correct : A. setw()

97. The function contain in the class iomanip to fill characters in the un used space

Correct : C. set fill()

98. The function contain in the ios class to fill characters in the blank space

Correct : C. fill()

99. The function contain in the ios class to specify number of decimal places

Correct : B. precision()

100. The function contain in the ios class to set flags

Correct : D. setf()