0% found this document useful (0 votes)
51 views50 pages

CS304 MidTerm File by Talha Sajid

Uploaded by

Talha Sajid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views50 pages

CS304 MidTerm File by Talha Sajid

Uploaded by

Talha Sajid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Mid-Term CS304(Object Oriented Programming) Page 1 of 50

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 2 of 50

1. Inheritance is a way to
a) organize data.
b) pass arguments to objects of classes.
c) add features to existing classes without rewriting them.
d) improve data-hiding and encapsulation.

2. Which part of an object exhibits its state?


a) Data
b) Operations
c) Any public part
d) Any private part

3. To convert from a user-defined class to a basic type, you would most likely use
a) a built-in conversion operator.
b) a one-argument constructor.
c) an overloaded = operator.
d) a conversion operator that‘s a member of the class

4. What problem(s) may occur when we copy objects without using deep copy constructor?
a) Dangling pointer

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 3 of 50

b) Memory Leakage
c) System crash
d) All of the given

6. this pointers are not accessible for static member functions.


a) True
b) False

7. A C++ class is similar to _____________


a) Structure
b) Header File
c) Library File
d) None of the given

8. a‘A static member function can be called, even when a class is not __________.
a) Declared
b) Define
c) Instantiated
d) Called

9. A static member function cannot be declared.


a) Static
b) Implicit
c) Explicit
d) Virtual

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 4 of 50

10. Friend functions are _____ functions of a class.


a) None of given
b) object member
c) non-member
d) data member

11. Which one of the following features of OOP is used to derive a class from another?
a) Encapsulation
b) Polymorphism
c) Data hiding
d) Inheritance

12. What is a class?


a) A class is a section of computer memory containing objects
b) A class is a section of the hard disk reserved for object oriented programs
c) A class is the part of an object that contains the variables.
d) A class is a description of a kind of object

13. _____, which means if A declares B as its friend it does NOT mean that A can access
private data
of B. It only means that B can access all data of A.
a) Friendship is one way only
b) Friendship is two way only
c) NO Friendship between classes

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 5 of 50

d) Any kind of friendship

14. Which of the following operators always takes no argument if overloaded?


a) /
b) -
c) +
d) ++

15. The statement objA=objB; will cause a compiler error if the objects are of different
classes.
a) True
b) False

16. Identify which of the following overloaded operator function’s declaration is


appropriate for the given call?
Rational_number_1 + 2.325
Where Rational_number_1 is an object of user defined class Rational_number.
a) Rational_number operator+( Rational_number & obj);
b) Rational_number operator+(double& obj);
c) Rational_number operator+(Rational_number &obj, double& num);
d) operator+(double& obj);

17. Which operator can not be overloaded?


a) The relation operator ( >= )

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 6 of 50

b) Assignment operator ( = )
c) Script operator ( [] )
d) Conditional operator (? : )

18. To convert from a user-defined class to a basic type, you would most likely use
a) a built-in conversion operator.
b) a one-argument constructor.
c) an overloaded = operator.
d) a conversion operator that’s a member of the class.

19. Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1 - obj2
to work correctly, if the overloaded - operator must
a) take two arguments.
b) return a value.
c) create a named temporary object.
d) take four arguments

20. The keyword that is used that the variable can not change state?
a) static
b) const
c) friend
d) private

21. The technique in which we visualize our programming problems according to real life’s
problems is called____________

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 7 of 50

a) structured programming
b) object oriented Programming
c) procedural programming
d) none of the given

22. In object orientated programming, a class of objects cans _____ properties from another
class of objects
a) Utilize
b) Borrow
c) Inherit
d) Adopt

23. Suppose obj1 and obj2 are two objects of a user defined class A. An + operator is
overloaded to add obj1 and obj2 using the function call obj1+obj2. Identify the correct
function prototype against the given call?
a) A operator + ( A &obj);
b) int + operator();
c) int operator (plus) ();
d) A operator(A &obj3);

24. A member function having the same name as that of a class and a ~ sign with it is called,
a) Constructor
b) Getter
c) Setter
d) Destructor

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 8 of 50

25. Using encapsulation we can achieve


a) Information hiding
b) Least interdependencies among modules
c) Implementation independence
d) All of given options

26. Suppose that the Test class does not have an overloaded assignment operator. What
happens when an assignment a=b; is given for two Test objects a and b?
a) The automatic assignment operator is used
b) The copy constructor is used
c) Compiler error
d) Run-time error

28. ____ provide the facility to access the data member.


a) accesser function
b) private function
c) inline function
d) None of the given

29. Constant objects cannot change their state,


a) True
b) False

30. The ____ relationship indicates that an object contains other objects.
a) ‘has-a’

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 9 of 50

b) ‘is-a’
c) ‘be-
d) None of given

31. Static variable can be initialized more than once.


a) True
b) False

32. For classes with common behavior, you can save effort by placing the common behavior
in a __________.
a) Derived Class
b) Base class
c) Deprived Class
d) Named class

33. _________ is a relationship


a) Inheritance
b) Polymorphism
c) abstraction
d) encapsulation

34. ___ satisfy the condition of polymorphism


a) Carbon
b) Diamond
c) Coal

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 10 of 50
d) all of the given

35. A generalization-specialization relation between classes are implemented using


a) data hiding
b) friend classes
c) encapsulation
d) inheritance

36. Which of the following are an advantage of OOP?


a) OOP makes it easy to re-use the code
b) It provides an ability to create one user defined data type by extending the other
c) It provides the facility of defining Abstract data types through which real world entities
can be defined better
d) All of the given options

37. The >= operator can be overloaded.


a) True
b) False

38. In order to free the memory occupied by the object, we use -------------
a) Constructor
b) Destructor
c) Shallow Copy
d) Deep Copy

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 11 of 50

39. Which of the following is not an example of multiple inheritances?----------


a) Mermaid
b) Woman
c) None of the given
d) Amphibious Vehicle

40. We can use "this" pointer in the constructor in the body and even in the initialization
list of any class if we are careful,
a) TRUE
b) False

41. A generic class showing all the common attributes and a behavior of other classes
represents a very important feature in oop called --------
a) Inheritance
b) Encapsulation
c) Polymorphism
d) Abstraction

42. We can get only one unique value which can be used by all the objects of that class by
the use of,
a) static variables
b) dynamic variables
c) instance variables
d) data members

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 12 of 50

43. Using encapsulation we can achieve


a) Information hiding
b) Least interdependencies among modules
c) Implementation independence
d) All of given options

44. Inheritance is a way to


a) make general classes into more specific classes.
b) pass arguments to objects of classes.
c) improve data hiding and encapsulation.
d) providing class growth through natural selection.

45. Static variables act like a global variable in the context or scope of the class.
a) True
b) False

46. The compiler won‘t object if you overload the * operator to perform division.
a) True
b) False

47. In OOP a class is an example of ___


a) Data Type
b) Abstract Type

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 13 of 50
c) User Defined Type
d) None of the given

48. A class can be identified from a statement by -------------


a) Pronoun
b) Verb
c) Adverb
d) Noun

49. Suppose there is an object of type Person, which of the following can be considered as
one of its attributes
a) Name
b) Age
c) Work()
d) Both Name and Age

50. The members of a class that can be accessed without creating the object of the class is
called________
a) Private member
b) Data Member
c) Public Member
d) Static

51. What a derived class can add?


a) New data members

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 14 of 50
b) New member functions and New friend functions
c) New constructors and destructor
d) All of given

52. ________ is/are used to access information hidden within an object?


a) Interface
b) Private data members
c) Private member functions
d) Both public and private members

53. C++ compiler does not allow to dynamically allocate memory for objects
a) False
b) True

54. Given the following class


class Base{
int Age=33;
}
How you can improve above class with respect to accessing the field Age?
a) Define the variable Age as private
b) Define the variable Age as protected
c) Define the variable Age as private and create a get method that returns it and a set
method that updates it
d) Define the variable Age as protected and create a set method that returns it and a get method
that updates it

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 15 of 50

55. Friend class and friend function can be used as an alternate to each other
a) True
b) False

56. We capture the object attributes and behavior in Object Oriented programming
using____________
a) Class
b) Function
c) Data Members
d) Instances

57. The return type of a constructor is of ____________


a) Integer
b) Character
c) Double
d) No type

58. What problem(s) may occur when we copy objects without using deep copy constructor?
a) Dangling pointer
b) Memory Leakage(Object is not deleted)
c) All of the given
d) System crash

59. Friend functions are _____________ functions of a class.

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 16 of 50
a) None of given
b) object member
c) non-member
d) data member

60. We achieve independence of internal implementation from its external interface


through________
a) Encapsulation
b) Information Hiding
c) Abstraction
d) both encapsulation and information hiding

61. Keeping in view the principle of abstraction, which of the above information the
company needs to save as employee’s record?
a) 2, 4
b) 1, 3, 5
c) 1, 2, 3
d) 1, 2, 3, 4

62. Which construct is the source for the creation of an object?


a) Destructor of the class
b) New operator
c) Delete operator
d) Constructor of the class

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 17 of 50
63. When a variable is define as static in a class then all object of this class,
a) Have different copies of this variable
b) Have same copy of this variable
c) Can not access this variable
d) None of given

64. __________remain in memory even when all objects of a class have been destroyed.
a) Static variables
b) Instance variable
c) Primitive variables
d) None of given

65. Given the following class


class Base{
int Age=33;
}
How you can improve above class with respect to accessing the field Age?
a) Define the variable Age as private
b) Define the variable Age as protected
c) Define the variable Age as private and create a get method that returns it and a set
method that updates it
d) Define the variable Age as protected and create a set method that returns it and a get method
that updates it

66. The life of sub object is not dependent on the life of master class in ___
a) Composition

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 18 of 50
b) Aggregation
c) Separation
d) None of the given

67. Which one is not keyword in C++?


a) operator
b) B_op
c) const
d) None of given

68. ___________, which means if A declares B as its friend it does NOT mean that A can
access private data of B. It only means that B can access all data of A.
a) Friendship is one way only
b) Friendship is two way only
c) NO Friendship between classes
d) Any kind of friendship

69. To convert from a user-defined class to a basic type, you would most likely use
a) a built-in conversion operator.
b) a one-argument constructor.
c) an overloaded = operator.
d) a conversion operator that‘s a member of the class.

70. Which of the following is a weak relationship between two objects?


a) Inheritance

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 19 of 50
b) Composition
c) Aggregation(the object can exist without master class like room and chair)
d) None of given

71. Which of the following is the way to extract common behavior and attributes from the
given classes and make a separate class of those common behaviors and attributes?
a) Generalization
b) Sub-typing
c) Specialization
d) Extension

72. The ability to derive a class from more than one class is called
a) Single inheritance
b) Encapsulation
c) Multiple inheritance
d) Polymorphism

73. If MyClass has a destructor what is the destructor named?


a) MyClass
b) ~MyClass
c) My~Class
d) MyClass~

74. If only one behaviour of a derived class is incompatible with base class, then it is:
a) Generalization

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 20 of 50
b) Specialization
c) Extension
d) Inheritance

75. Which of the following may not be an integral part of an object?


a) state
b) behavior
c) Protected data members
d) All of given

76. Consider the code below, class class1{ public: void func1(); }; class class2 : protected
class1 { }; Function func1 of class1 is ______ in class2,
a) public
b) protected
c) private
d) none of the given options

77. In case of dynamic memory allocation in a class we should use,


a) User defined default constructor
b) User defined copy constructor
c) Both of these
d) None of these

78. A template provides a convenient way to make a family of


a) variables and data members

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 21 of 50
b) functions and classes
c) classes and exceptions
d) programs and algorithms

79. Which one of the following terms must relate to polymorphism?


a) Static allocation
b) Static typing
c) Dynamic binding
d) Dynamic allocation

80. What is true about function templates?


a) The compiler generates only one copy of the function template
b) The compiler generates a copy of function respective to each type of data
c) The compiler can only generate copy for the int type data
d) None of the given.

81. Which of the following is the best approach if it is required to have more than one
functions having exactly same functionality and implemented on different data types?
a) Templates
b) Overloading
c) Data hiding
d) Encapsulation

82. template <>


class Vector<char*> { }

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 22 of 50
This is an example of partial specialization.
a) True
b) False

83. Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be


concrete, while classes like Sphere and Cube would normally be abstract.
a) True
b) False

84. A non-virtual member function is defined in a base class and overridden in a derived
class; if that function is called through a base-class pointer to a derived class object, the
derived-class version is used.
a) True
b) False

85. In order to define a class template, the first line of definition must be:
a) template <typename T>
b) typename <template T>
c) Template Class <ClassName>
d) Class <Template T>

86. If there is a pointer p to objects of a base class, and it contains the address of an object
of a derived class, and both classes contain a nonvirtual member function, ding(), then the
statement p->ding(); will cause the version of ding() in the ___ class to be executed.

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 23 of 50
a) Base
b) Derived
c) Abstract
d) Virtual

87. Non Template Friend functions of a class are friends of ____instance/s of that class.
a) All
b) One specific
c) All instances of one date type
d) None of the given options

88. Consider the code below, class class1{ public: int i; }; class class2 : public class1 { }; Then
int member i of class1 is ______ in class2,
a) public
b) protected
c) private
d) none of the given options

89. We can call base class constructor from derived class constructor,
a) From derived class constructor body
b) From the initializer list of derived class constructor
c) From any member function of derived class
d) We can not call the base class constructor

90. Public Inheritance represents,

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 24 of 50
a) “IS A” relationship
b) “Has A” relationship
c) “IS Special Kind of” relationship
d) None of these options

91. Function overloading is done with respect of,


a) A single class
b) A derived class
c) A base class
d) Both derived and base classes

92. By default, assignment operator (=) performs,


a) Shallow copy
b) Deep copy
c) Both of these
d) None of the above

93. The find() algorithm


a) finds matching sequences of elements in two containers.
b) finds a container that matches a specified container.
c) takes iterators as its first two arguments.
d) takes container elements as its first two arguments.

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 25 of 50
94. If you define a vector v with the default constructor, and define another vector w with a
one-argument constructor to a size of 11, and insert 3 elements into each of these vectors
with push_back(), then the size() member function will return __ for v and ___ for w.
a) 11 for v and 3 for w.
b) 0 for v and 0 for w.
c) 0 for v and 3 for w.
d) 3 for v and 11 for w.

95. Which is not the Advantage of inheritance?


a) providing class growth through natural selection.
b) facilitating class libraries.
c) avoiding the rewriting of code.
d) providing a useful conceptual framework

96. Sender of the message does not need to know the exact class of receiver in________.
a) Abstraction
b) Polymorphism
c) Inheritance
d) none of the given

97. In c , compiler can generate which of the following operators‟ code,


a) ==
b) =
c) &
d) &&

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 26 of 50

98. Virtual functions allow you to


a) create an array of type pointer-to-base class that can hold pointers to derived classes.
b) create functions that can never be accessed.
c) objects of different classes so they can all be accessed by the same function code.
d) use the same function call to execute member functions of objects from different classes.

99. Two functions with same names, parameters and return type can exist in,
a) Function overloading
b) Function overriding
c) Operator overloading
d) None of the above

100. Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { };
Then c2 is,
a) Direct base class of c3
b) Direct child class of c3
c) Direct base class of c1
d) None of these

101. In case of dynamic memory allocation in a class we should use,


a) User defined default constructor
b) User defined copy constructor
c) Both of these
d) None of the above

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 27 of 50

102. Which of the following is the best approach if it is required to have more than one
functions having exactly same functionality and implemented on different data types?
a) Templates
b) Overloading
c) Data hiding
d) Encapsulation

103. Assume a class Derv that is privately derived from class Base. An object of class Derv
located in main() can access
a) public members of Derv.
b) protected members of Derv.
c) private members of Derv.
d) protected members of Base.

104. When the base class and the derived class have a member function with the same name,
you must be more specific which function you want to call (using ___________).
a) scope resolution operator
b) dot operator
c) null operator
d) Operator overloading

105. Non Template Friend functions of a class are friends of ________instance/s of that class.
a) All
b) One specific
c) All instances of one date type

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 28 of 50
d) None of the given options

106. Which of the following may not be an integral part of an object?


a) State
b) Behavior
c) Protected data members
d) All of given

107. class DocElement


{
public:
virtual void Print() { cout << "Generic element"; }
};
class Heading : public DocElement
{
public:
void Print() { cout << "Heading element"; }
};
class Paragraph : public DocElement
{
public:
void Print() { cout << "Paragraph element"; }
};
void main()

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 29 of 50
{
DocElement * p = new Paragraph();
p->Print();
}
When you run this program, it will print out a single line to the console output.
What will be in that line?
a) Generic element
b) Heading element
c) Paragraph element
d) Nothing will be printed.

108. When a virtual function is called by referencing a specific object by name and using
the dot member selection operator (e.g., squareObject.draw()), the reference is resolved at
compile time.
a) True
b) False

109. In case of multiple inheritance a derived class inherits____


a) Only the public member functions of its base classes
b) Only the public data members of its base classes
c) Both public data members and member functions of all its base classes
d) Data members and member functions of any two base classes

110. Which of the following is incorrect line regarding function template?


a) template<class T>

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 30 of 50
b) template <typename U>
c) Class<template T>
d) template < class T, class U>

111. An STL container can not be used to,


a) hold objects of class employee.
b) store elements in a way that makes them quickly accessible.
c) compile c++ programs.
d) organize the way objects are stored in memory

112. Algorithms can only be implemented using STL containers.


a) True
b) False

113. Consider the code below,


class Fred {
public:
Fred();
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 31 of 50
...
}
Select the best option,
a) Fred a[10]; calls the default constructor 09 times Fred* p = new Fred[10]; calls the default
constructor 10 times
b) Produce an error
c) Fred a[10]; calls the default constructor 11 times Fred* p = new Fred[10]; calls the
default constructor 11 times
d) Fred a[10]; calls the default constructor 10 times Fred* p = new Fred[10]; calls the default
constructor 10 times

114. When a variable is define as static in a class then all object of this class,
a) Have different copies of this variable
b) Have same copy of this variable
c) Can not access this variable
d) None of given

115. The life of sub object is dependent on the life of master class in _____________.
a) Separation
b) Composition
c) Aggregation
d) None of the given

116. In Private __________ only member functions and friend classes or functions of a
derived class can convert pointer or reference of derived object to that of parent object
a) specialization

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 32 of 50
b) inheritance
c) abstraction
d) composition

117. template argument is preceded by the keyword ________.


a) vector
b) class
c) template
d) type*

118. Which of the following causes run time binding?


a) Declaring object of abstract class
b) Declaring pointer of abstract class
c) Declaring overridden methods as non-virtual
d) None of the given

119. A function template can not be overloaded by another function template.


a) True
b) False

120. Identify the correct way of declaring an object of user defined template class A for char
type members?
a) A< char > obj;
b) <char>A obj;
c) A obj<char>;

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 33 of 50
d) Obj <char> A;

121. Template functions use _________ than ordinary functions.


a) Greater Memory
b) Lesser Memory
c) Equal Memory
d) None of the given options

122. Compiler performs ________ type checking to diagnose type errors,


a) Static
b) Dynamic
c) Bound
d) Unbound

123. Which of the following is/are advantage[s] of generic programming?


a) Reusability
b) Writability
c) Maintainability
d) All of given

124. Suppose you create an uninitialized vector as follows:


vector<int> evec;
After adding the statment,
evec.push_back(21);

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 34 of 50
what will happen?
a) The following statement will add an element to the start (the back) of evec and will
initialize it with the value 21.
b) The following statement will add an element to the center of evec and will reinitialize it
with the value 21.
c) The following statement will delete an element to the end (the back) of evec and will
reinitialize it with the value 21.
d) The following statement will add an element to the end (the back) of evec and initialize it
with the value 21.

125. In a de-queue, (chose the best option)


a) data can be quickly inserted or deleted at any arbitrary location.
b) data can be inserted or deleted at any arbitrary location, but the process is relatively slow.
c) data can not be quickly inserted or deleted at either end.
d) data can be inserted or deleted at either end, but the process is relatively slow.

126. Default constructor is such constructor which either has no _________or if it has some
parameters these have __________ values
a) Parameter, temporary
b) Null, Parameter
c) Parameter, default
d) none of the given

127. Public methods of base class can --------- be accessed in its derived class
a) directly
b) indirectly
c) simultaneously

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 35 of 50
d) none of the given

128. The type that is used to declare a reference or pointer is called its ---------
a) default type
b) static type
c) abstract type
d) reference type

129. Which of these are examples of error handling techniques ?


a) Abnormal Termination
b) Graceful Termination
c) Return the illegal
d) all of the given

130. ____________ follow try block to catch the object thrown


a) catch block
b) throw block
c) main block
d) none of the given

131. Graphical representation of the classes and objects is called object model it
shows______
a) Class Name only
b) Class Name and attributes
c) Relationships of the objects and classes

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 36 of 50
d) all of the given

132. Destructor can be overloaded


a) True
b) False

133. Outside world can access only __________ members of a class using its object.
a) Public
b) Private
c) Protected
d) No member is accessible

134. Consider the code below, class class1{ private: int i; }; class class2 : protected class1 {
};
Then int member i of class1 is ______ in class2,
a) public
b) protected
c) private
d) none of the given options

135. Consider the code below, class class1{ protected: int i; }; class class2 : public class1 { };
Then int member i of class1 is ______ in class2,
a) public
b) protected

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 37 of 50
c) private
d) none of the given options

136. ___________ Binding means that target function for a call is selected at run time
a) Automatic
b) Dynamic
c) Static
d) Dramatic

137. In Protected Inheritance the public members of base class become __________ in
derived class.
a) Public
b) Private
c) Protected
d) None of the given options.

138. Suppose both derive and base classes have compiler generated copy constructors then
derived class copy constructor will call base class __________,
a) Compiler generated default constructor
b) Compiler generated copy constructor
c) Both of these options are correct
d) None of these options are correct

139. Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { };
Then c3 is,

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 38 of 50
a) Direct base class of c1
b) Direct child class of c1
c) Direct base class of c2
d) Direct child class of c2

140. In specialization we can,


a) Replace child class with its base class
b) Replace base class with its child class
c) Replace both child and base classes interchangeably
d) None of the given options

141. A copy constructor is invoked when


a) a function do not returns by value.
b) an argument is passed by value.
c) a function returns by reference.
d) an argument is passed by reference.

142. A function call is resolved at run-time in___________


a) non-virtual member function.
b) virtual member function.
c) Both non-virtual member and virtual member function.
d) None of given

143. When the base class and the derived class have a member function with the same name,
you must be more specific which function you want to call (using ___________).

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 39 of 50
a) scope resolution operator
b) dot operator
c) null operator
d) Operator overloading

144. Two important STL associative containers are _______ and _______.
a) set, map
b) sequence, mapping
c) setmet, multipule
d) sit, mat

145. The mechanism of selecting function at run time according to the nature of calling
object is called,
a) late binding
b) static binding
c) virtual binding
d) None of the given options

146. An abstract class is useful when,


a) We do not derive any class from it.
b) There are multiple paths from one derived class to another.
c) We do not want to instantiate its object.
d) You want to defer the declaration of the class.

147. By default the vector data items are initialized to ____

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 40 of 50
a) 0
b) 0.0
c) 1
d) Null

148. Which one of the following functions returns the total number of elements in a vector.
a) length();
b) size();
c) ele();
d) veclen();

149. The main function of scope resolution operator (::) is,


a) To define an object
b) To define a data member
c) To link the definition of an identifier to its declaration
d) To make a class private

150. All of the given choices this pointer does not pass implicitly to __________ functions.
a) Static Member
b) Non-Static Member
c) Instance Number
d) None of the given

151. If a class involves dynamic memory allocation, then:


a) Default copy constructor, shallow copy is implement

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 41 of 50
b) User defined copy constructor, shallow copy is implement
c) Default copy constructor, deep copy is implemented
d) User defined copy constructor, deep copy is implement

152. Three main characteristics of "Object Oriented programming" are,


a) Encapsulation,dynamic binding,polymarhpishm
b) polymorphism, overloading, overriding
c) encapsulation, inheritance, dynamic binding
d) encapsulation, inheritance, polymorphism

153. Suppose you have been given the following design, _____A person has a name, age,
address and _____. You are designing a class to represent a type of person called a patient.
This kind of person may be given a diagnosis, have a spouse and may be alive. Given that
the person class has already been created, what of the following would be appropriate to
include when you design the patient class?
a) registration date and diagnosis
b) age and —–
c) and diagnosis
d) diagnosis and age

154. Object Data includes_____


Both static and attributes of an objects

155. Which of the following is the correct syntax of declaring static variable ‘count’ of type
int?

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 42 of 50
Static int count

156. Which of the following will happen when a constant function tries to change the value
of data members of the class?
Complex time error will occur

157. Suppose you have following C++


statements IntoldValue=10
intviewValue * ++ old/Value
What will be the value of old/Value and new/Value after executing above statement?
Old/Value=11, new/Value=11

158. An objects has attributes, operations and


Unique identity

159. In Object Oriented programming objects communicate with each other through
Messages

160. Identify the abstract class from the given statement


“vehicle class is base class. Bus, Car and truck are derived classes”

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 43 of 50
Vehicle

161. Suppose test is a class, void show() is its public member function. Which of the following
is
correct call of
Show() function using Test pointer
ptr?
Ptr->show()

162. Relationship in which child object gets destroyed, If parent object is


destroyed.
Composition

163. How many objects of a given class may be constructed in an


application?
As many as the application asks for

164. In_____base class can be replaced by the derived


class.
Extension

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 44 of 50

165. Minimum classes required for implementing multiple inheritance.


At least 3

166. Composition is_____ and aggregation is ____relationship.


Strong, weak

167. Which of the following represents the two-way association?


Employee works for the company

168. Which of the following is an advantage of encapsulation?


Better understanding

169. Which of the following statement best describes the constructor


Constructor is used to initialize the data member of a class.

170. Suppose person is a class which of the following statement defines an object of class
person?
Create person object

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 45 of 50

171. If you have three classes in a C++ program A, B, and C where class A inherits from
class B, then class _______contains all the characteristics of class_______
A,C

172. Which of the following is the example of objects in school?


Books , pages

173. A post-fix unary operator is implemented in C++ member function with


1 dummy int arguments

174. Memory is allocated to non static members only, when


Object is created

175. _________is creating objects of one class inside another class.


Composition

176. What is the general syntax of overloading Unary Operator as member function of the
class?
TYPE & operator OP ();

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 46 of 50

177. Which of the following function declaration is correct to overload the + operator as
member function in complex class?
Complex operator +(const Complex &rhs);

178. We can get the address of a variable stored in a pointer using


& symbol

179. In______, base class can be replaced by the derived class.


Extension

180. In case when we define the function outside the class then we must use the keyword
________To make the function inline.
Inline

181. Which of the following classes are used by Amphibious vehicle to inherit
characteristics?
Both Land & Water Vehicle

182. In polymorphism, messages can be interpreted in different ways depending upon the

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 47 of 50
class.
Receiver

183. Insertion operator is__________ associative.


Left to Right

184. Generalization is __________approach.


Top-bottom

185. How many objects are involved in the N-ary association?


More than 3

186. When derived class has user defined assignment operator.


Compiler itself calls base class default constructor.

187. In C++ generic programming is done using____


Packages

188. Methodologies to the development of reusable software relate to_________.

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 48 of 50
Generic programming

189. In statement template <class T,class U ,int |=5> the non-parameter is________.
Class U

190. _________is a pointer which is declared outside the_______


Cursor, Container

191. Each _______of a template class by default becomes function template.


Member function

192. Which of the following is the correct syntax of declaring static variable “count” of type
int?
Static int count;

193. In case of private inheritance, private members of base class will be _______in derived
Class.
Hidden

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 49 of 50
194. Suppose we have defined derived class copy constructor but have not defined base class
Copy constructor then compiler will,
Use base class default constructor

195. Which of the following is a sequence Container?


Vector

196. The parameters given in template definition other than those used for mentoring
templates types are called________
Non-type parameters

197. Class is blueprint of .


Objects

198. In resolution order compiler search firstly.


Ordinary function

199. What will the value of variables a, b, and c after instantiating an object of above class?
Junk Value, 5, Junk value

Whatsapp 0328-4090195
Mid-Term CS304(Object Oriented Programming) Page 50 of 50
200. What is the output of the following code?Int main()
{intconst x = 10; cout<< ++x; return 0;}
11

201. If there is a pointer p to objects of a base class , and it contains the address of an object
of a derived Class, and both classes contain a virtual member function, ding(), then the
statement p->ding(); will cause the version of ding() in the class to be executed.
Derived
202. In C++ by default access of classes is.
Private

Best of Luck

For Free help, more Mid/Final term Files and for Exam Preparation You Can
Join:

https://chat.whatsapp.com/F094bNv5NKYD23JUH7AAY8

Whatsapp 0328-4090195

You might also like