0% found this document useful (0 votes)
65 views143 pages

CS304 Mega MCQS

This document contains 50 multiple choice questions about object oriented programming concepts in C++. It was solved by Junaid Malik and team from Al-Junaid Institute Group. The questions cover topics such as inheritance, encapsulation, polymorphism, constructors, destructors, operator overloading, templates and memory management in C++.

Uploaded by

Umer
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)
65 views143 pages

CS304 Mega MCQS

This document contains 50 multiple choice questions about object oriented programming concepts in C++. It was solved by Junaid Malik and team from Al-Junaid Institute Group. The questions cover topics such as inheritance, encapsulation, polymorphism, constructors, destructors, operator overloading, templates and memory management in C++.

Uploaded by

Umer
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/ 143

CS304-Object Oriented Program

Solved MCQS for Final terms papers


Solved by JUNAID MALIK and Team
AL-JUNAID INSTITUTE GROUP

1. Function func1of class1 is _ in class2.


► Public
► Protected
► Private
► None of the given
2. The default inheritance mode is,
a) Public inheritance
b) Protected inheritance
c) Private inheritance
d) None of the given
3. A template provides a convenient way to make a family of
a) Variables and data members
b) Functions and classes
c) Classes and exceptions
d) Programs and algorithms
4. Then int member i of base class is accessible in class,
a) derived 1 only
b) derived 2 only
c) both derived 1 derived 2
d) none of the given options
5. In case of public inheritance, protected members of base class will be in derived class?
a) Private
b) Public
c) Protected
d) hidden
6. By default assignment operator (=) performs,
a) Shallow copy
b) Deep copy
c) Both of these
d) None of these
7. In protected inheritance the public members of base class become _ in derived class.
a) Public
b) Private
c) Protected
d) None of the given
8. We can access public members of the class from outsides the class using operator with its
object pointer
a) ->
AL-JUNAID INSTITUTE GROUP
b) .
c) &
d) @
9. Compiler can automatically generates the following constructor/s for a class,
a) Default constructor
b) Copy constructor
c) Both of these
d) None of these
10. Friend’s functions of class are _ members of that class.
a) Public
b) Private
c) Protected
d) None of the given
11. Methodologies to the development of reusable software relate to .
a) Structure programming
b) Procedural programming
c) Generic programming
d) None of the given
12. Function overriding is done in context of,
a) Single class
b) Single derived class
c) Single base class
d) Derived and base classes
13. Which of the following is not type of inheritance in c++?
a) Public
b) Protected
c) Restricted
d) Private
14. 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.
a) Base
b) Derived
c) Virtual
d) Implemented
15. Target class of a function call is determined t run time.
a) Instance
b) Virtual
c) Operator
d) None of the given
16. In c++ dynamic binding and polymorphism will be achieved when the member function will
be_
AL-JUNAID INSTITUTE GROUP
a) Private
b) Public
c) Virtual
d) Inline
17. To make a pure virtual, we need to give _after() of this function.
a) =0;
b) =1;
c) Null;
d) None of the given
18. If we have not given any constructor for the class,compiler generates which of the following
constructors?
a) Emplicit Default
Constructor b) Implicit Default
Constructor
c) Emplicit Parameterized Constructor
d) Implicit Parameterized Constructor
19. In c++ by default access of classes is .
a) Private
b) Protected
c) Public
d) None of the given
20. In public inheritance the public members of base class become in derived class
a) Private
b) Protected
c) Public
d) None of the given
21. A class hierarchy
a) Shows the same relationships as a organization chart
b) Describe “has a “relationship.
c) Describe “is a kind of” relationship.
d) Shows the same relationships as a family tree.
22. In private Inheritance the public members of the base class become in derived class
a) Public
b) private
c) Protected
d) None of the given option
23. In the line No.2, which constructor of student class will be
a) Default constructor of student class
b) Copy constructor of student class
c) Both Default and Copy constructor of student class
d) No constructor will be called
24. Which of the following is Not casting operator in c++ standard?
a) Static-cast
AL-JUNAID INSTITUTE GROUP
b) Var-cast
c) Dynamic-cast
d) Reinterpret-cast
25. Which of the following type of inheritance is used to model “Implemented in terms of”
relationship?
a) Public
b) Private
c) Protected
d) Confidential
26. When we want to implement one class in terms of another class then we use, a)
Public inheritance
b) Protected inheritance
c) Private inheritance
d) None of these options
27. Public inheritance represents;
a) “IS A “relationship
b) “Has A” relationship
c) “IS Special kind of” relationship
d) None of these option
28. Suppose we have defined derived class copy constructor but have not defined base class copy
constructor then compiler will,
a) Use base class default constructor
b) Generate base class copy constructor itself
c) Use base class assignment operator
d) Nine of these option is correct
29. Child class can call constructor of
its, a) Direct base class
b) Indirect base class
c) Both direct and indirect base classes
d) None of these
30. We can have type of member functions in a class.
a) Public
b) Private
c) Protected
d) All of these options
31. Compiler generated copy constructor performs
a) Shallow copy
b) Deep copy
c) Both Shallow and Deep copy
d) None of these options
32. In c++ generic programming is done using
a) Procedures
AL-JUNAID INSTITUTE GROUP
b) Packages
c) Templates
d) None of the given
33. Target class of a function call is determined at run time.
a) Instance
b) Virtual
c) Operator
d) None of the given
34. Suppose person is a user defined class.In statement “Person*pPtr”, static type of pPtr is ----.
a) pPtr
b) pointer
c) person
d) None of the given
35. Which statement is true for concrete class?
a) It cannot be inherit from an abstract class
b) It can be instantiated
c) It cannot be instantiated
d) None of given
36. In c++, compiler can generate which of the following operators ‘code,
a) ==
b) =
c) &
d) &&
37. 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 classesinterchangeably
d) None of the given option
38. In private inheritance derived class pointer can be assigned to base class pointer in,
a) Main function
b) In derived class member and friend class function
c) In base class member and friend functions
d) None of the given option
39. When we access private members of the class from outside the class using operator with its
object pointer
a. ->
b. .
c. &
d. None of above
40. Which of the following access specifier ensure that base class member is accessible in derived
class and Not outside of this class
a. Public
AL-JUNAID INSTITUTE GROUP
b. Private
c. Protected
d. All of above
41. Static casting is
a. C++ way of calling base class function from derived class
b. C way of calling base class function from derived class
c. Both of these
d. None of these
42. Suppose both derive and base classes have compilers generated copy constructors then derived
class copy construct is
a. Compiler generated default constructor
b. Compiler generated copy constructor
c. Both of these options are correct
d. None of these operators are correct
43. In case of protected inheritance, public members of the base class will be in derived class
a. Private
b. Public
c. Protected
d. Hidden
44. Methodologies to the development of reusable software related to
a. Structured programming
b. Procedural programming
c. Generic programming
d. None of the given
45. A child class can call constructor of the parent call through
a. Its constructor initialization list
b. Its constructor body
c. Both from its constructor initialization list or body
d. Cannot call the constructor of its parent class
46. In case of dynamic memory allocation in or class we should use
a. Default assignment operator
b. User defined assignment operator
c. Default copy constructor
d. None of these
47. Consider the code below.
Class class1{
Protected:
Int I;
};
Class class2: private calls 1{
};
a) Public
AL-JUNAID INSTITUTE GROUP
b) Protected
c) Private
d) None of the given options

48. Consider the following two lines of code written for class student
1. Student sobj1;
2. Student sobj2(sobj1)

In line 2 which constructor of student class will be called?

a) Default constructor of student class


b) Copy constructor of student class
c) Both default and copy constructor of student class
d) No constructor will be called
49. Which of the following is /are casting operator(s) inc++?
a. Static_cast
b. Const_cast
c. Dynamic_cast
d. All of the given options
50. In case of private inheritance, private members of base class will be in derived class?
a. Private
b. Public
c. Protected
d. Hidden
51. Consider the code below
class class1{
Private:
Void func1();
};
Class class2 : public class1{
};
Function func1 of class 1 is in class2.
a. Public
b. Protected
c. Private
d. None of the given options
52. We can call base class assignment operator in derived class user defined assignment operator
a. Implicitly
b. Explicitly
c. Using both of these options
d. Using none of these options
53. A function call is resolved at run time in
AL-JUNAID INSTITUTE GROUP
a. Non virtual members functionb. Virtual member
function
c. Both none-virtual and virtual member function
d. None of given
54. If the user does not specify the type if inheritance, then the default type of inheritance is
a. Public inheritance b. Private
inheritance
c. Protected inheritance
d. None of given
55. Consider the code belowclass class1{
public:
Void func1();
};
Class class2: protected class1{
};
Function func1 of class 1 is in class2.
a. Public
b. Protected
c. Private
d. None of the given options

56. Which of the following causes run time binding?

► Declaring object of abstract class


► Declaring pointer of abstract class
► Declaring overridden methods as non-virtual ► (Page 226)
None of the given

57. 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?

► Templates (Page 256)


► Overloading
► Data hiding
► Encapsulation

58. A copy constructor is invoked when

► a function do not returns by value.


► an argument is passed by value. (Page 78)
► a function returns by reference.
► an argument is passed by reference.

59. Like template functions, a class template may not handle all the types successfully.

`
AL-JUNAID INSTITUTE GROUP
► True (Page 258)
► False

60. A class template may inherit from another class template.

► True (Page 288)


► False

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


► 0 google
► 0.0
►1
► null
62. 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

►specialization
► inheritance (Page 216)
► abstraction
► composition

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


► Reusability
► Writability
► Maintainability
► All of given (Page 256)

64. Template functions use _________ than ordinary functions.

► Greater Memory
► Lesser Memory
► Equal Memory
► None of the given options

65. Non Template Friend functions of a class are friends of ________instance/s of that class.

► All google
► One specific
► All instances of one date type
► None of the given options
66. A pointer to a base class can point to objects of a derived class.

► True google
► False

`
AL-JUNAID INSTITUTE GROUP
67. A template argument is preceded by the keyword ________.
► vector
► class
► template
► type*
68. Which one of the following terms must relate to
polymorphism?
► Static allocation
► Static typing
► Dynamic binding (Page 239)
► Dynamic allocation

69. Multiple inheritance can be of type

► Public
► Private
► Protected
► All of the given

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

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


► non-virtual member function.
► virtual member function. (Page 239)
► Both non-virtual member and virtual member function.
► None of given

72. Two important STL associative containers are _______ and _______.

► set,map
► sequence,mapping
► setmet,multipule
► sit,mat

73. An abstract class is useful when,

► We do not derive any class from it.


► There are multiple paths from one derived class to another.
► We do not want to instantiate its object
► You want to defer the declaration of the class.

`
AL-JUNAID INSTITUTE GROUP
74. Suppose you create an uninitialized vector as follows:

vector<int> evec;
After adding the statment,
evec.push_back(21);
what will happen?
► The following statement will add an element to the start (the back) of evec and will initialize it
with the value 21.
► The following statement will add an element to the center of evec and will reinitialize it with the
value
21.
► The following statement will delete an element to the end (the back) of evec and will
reinitialize it with the value 21.
► The following statement will add an element to the end (the back) of evec and initialize it with the
value 21.

75. Default constructor is such constructor which either has no ---------or if it has some parameters these
have -----
--- values

► Parameter, temporary
► Null, Parameter
► Parameter, default (Page 75)
► non of the given

76. Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete,


while classes like Sphere and Cube would normally be abstract.
► True
► False
77. In order to define a class template, the first line of definition must be:

► template <typename T> (Page 257)


► typename <template T>
► Template Class <ClassName>
► Class <Template T>

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

► True

`
AL-JUNAID INSTITUTE GROUP
► False

79. Identify the correct way of declaring an object of user defined template class A for char type members?

► A< char > obj;


► <char>A obj;
► A obj<char>;
► Obj <char> A;
80. The user must define the operation of the copy constructor.

► True
► False

81. The find() algorithm

► finds matching sequences of elements in two containers.


► finds a container that matches a specified container.
► takes iterators as its first two arguments. (Object-Oriented Programming in C++)
► takes container elements as its first two arguments.

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

► Static (Page 261)


► Dynamic
► Bound
► Unbound

83. Vectors contain contiguous elements stored as a[an] ___.

► variable
► array (Page 306)
► function
► datatype

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

► data can be quickly inserted or deleted at any arbitrary location.


► data can be inserted or deleted at any arbitrary location, but the process is relatively slow.
► data can not be quickly inserted or deleted at either end.
► data can be inserted or deleted at either end, but the process is relatively slow.

85. Algorithms can only be implemented using STL


containers.

`
AL-JUNAID INSTITUTE GROUP
► True
► False(Object-Oriented Programming in C++)

86. What is a class?

► A class is a section of computer memory containing objects.


► A class is a section of the hard disk reserved for object oriented programs
► A class is the part of an object that contains the variables.
► A class is a description of a kind of object. Click here for detail

87. Inheritance is a way to

► organize data.
► pass arguments to objects of classes.
► add features to existing classes without rewriting them. (Page 27)
► improve data-hiding and encapsulation.

88. We can use "this" pointer in the constructor in the body and even in the initialization list of any class if
we are careful,
► True
► False

89. ________ and ______ methods may not be declared abstract.

► private,staticClick here for detail


► private,public
► static,public
► none of given

90. ------------- members are somewhere between public and private members. They are used in
inheritance

► protected
► public
► private
► global (Page 187)

`
AL-JUNAID INSTITUTE GROUP
91. Which of these are examples of error handling techniques?

► Abnormal Termination
► Graceful Termination
► Return the illegal
► all of the given (Page 329)

92. ----------------- follow try block to catch the object thrown

► catch block (Page 333)


► throw block
► main block
► non of the given

93. Graphical representation of the classes and objects is called object model it shows -------

► Class Name only


► Class Name and attributes
► Relationships of the objects and classes
► all of the given

94. Destructor can be overloaded

► True

► False(Page 92)

95. Which of the following is the best approach to implement generic algorithms with minimum number of
coding lines?

► Templates (Page 256)


► Overloading
► Overriding
► Friend function/class

`
AL-JUNAID INSTITUTE GROUP
96. Each try block can have ______ no. of catch blocks.

►1
►2
►3
► As many as necessary.

97. 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()
{
DocElement * p = new Paragraph();

`
AL-JUNAID INSTITUTE GROUP
p->Print();
}
98. When you run this program, it will print out a single line to the console output.

What will be in that line?

Select one correct answer from the following list:

► Generic element ►
Heading element
► Paragraph element
► Nothing will be printed.

99. Suppose we have two derived classes from a single class, can we write a method with same name in
both these derived classes? Choose the best option.
► No
► Only if the two classes have the same name (Page 204)
► Only if the main program does not declare both kinds
► Yes

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

► True
► False
101. Considering the resolution order in which Considering the resolution order in which compiler search
for functions in a program; the first priority is given to; the first priority is given to,

► general template
► partial specialization
► complete specialization
► ordinary function (Page 287)

102. One purpose of an iterator in the STL is to connect algorithms and containers.

►True
► False

103. In ________, a base class can be replaced by its derived class,

► Sub-typing (Page 31)


► Super-typing
► Multiple-typing
► Restricted-typing

`
AL-JUNAID INSTITUTE GROUP
104. one this pointer does not point to current object
of any class,
► True
► False

105. Which of the following operator(s) take(s) one or no argument if overloaded?

► ++(Page 162)
►-
►+
► All of the given

106. Which of the following operators can not be


overloaded?

► Scope resolution operator ( :: ) (Page 141)


► Insertion operator ( << )
► Extraction operator ( >> )
► The relation operator ( > )

107. Which of these are examples of error handling


techniques ?
► Abnormal Termination
► Graceful Termination
► Return the illegal
► all of the given (Page 329)

108. _______ “is a” relationship

► Inheritance (Page 25)

`
AL-JUNAID INSTITUTE GROUP
► Polymarphism
► abstraction
► encapsulation

109. Virtual functions allow you to

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

110. The copy() algorithm returns an iterator to

► the last element copied from.


► the last element copied to.
► the element one past the last element copied from.
► the element one past the last element copied to.

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

► 11 for v and 3 for w.


► 0 for v and 0 for w.
► 0 for v and 3 for w.
► 3 for v and 11 for w.
112. Which is not the Advantage of inheritance?

► providing class growth through natural selection. (Object-Oriented Programming in


C++)
► facilitating class libraries.
► avoiding the rewriting of code.
► providing a useful conceptual framework.

113. Which type of inheritance is being represented by the following statement, class
X : public A, public B { ... ... };

► Single inheritance
► Multiple inheritance (Page 41)

`
AL-JUNAID INSTITUTE GROUP
► Double inheritance
► None of the given options

114. When we write a class template the first line must be:

► template < class class_name>


► template < class data_type>
► template < class T > (Page 257)

115. Function templates should be used where code and behavior must be identical.
► True (Page 262)
► False

116. The specialization pattern <T*> after the name says that this specialization is to be used for
every,
► data type
► meta type
► virtual type
► pointer type (Page 286)

117. A range is often supplied to an algorithm by two _______ values.


► italic
► iteration (Object-Oriented Programming in C++)
► iterator
► None of given

118. Which of the following is an integral part


of an object?

► State
► Behavior
► Unique identity
► All of the given (Page 12)

119. Consider the following statement

Cupboard has books


What is the relationship between Cupboard and books?

► Composition
► Aggregation
► Inheritance
► None of the given options

120. Which sentence clearly defines an object?

► one instance of a class. (Page 23)

`
AL-JUNAID INSTITUTE GROUP
► another word for a class.
► a class with static methods.
► a method that accesses class attributes.

121. ___________, 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.

► Friendship is one way only


► Friendship is two way only
► NO Friendship between classes
► Any kind of friendship

122. The statement objA=objB; will cause a compiler error if the objects are of different classes.

► True
► False

123. Consider the call given below of an overloaded


operator "+", Rational_number_1 +
Rational_number_2
Where Rational_number_1 and Rational_number_2 are the two objects of Rational_number
class (a user defined class). Identify which of the above two objects will be passed as an
argument to the overloaded operator function?

► Rational_number_1
► Rational_number_2
► Both Rational_number_1 & Rational_number_2
► any of the two objects, randomly

124. If a class D has been derived using protected inheritance from class B (If B is a protected
base and D is derived class) then public and protected members of B -------- accessed by
member functions and friends of class D and classes derived from D
► can be
► cannot be
► does restirct to be
► not given

`
AL-JUNAID INSTITUTE GROUP
The type that is used to declare a reference or pointer is called its___________

► abstract type
► reference type
► ► static type
► defaulttype

125. How the information hidden within an object can be accessed?


► Through its interface
► Through its private data members
► Through its private member functions
► Through both public and private members

126. The sub-object’s life is not dependant on the life of master class in __________.
► Separation
► Composition

► None of the given

127. Encapsulation means


Select correct option:
►Extending the behaviour of class in another class
►Data and behaviour are tightly coupled within an entity (Page 16)
►One entity takes all the attributes and operations of the other
►Taking out the common features and put those in a separate class

128. An STL container can not be used to,

► hold objects of class employee.


► store elements in a way that makes them quickly accessible.
► compile c++ programs. (Object-Oriented Programming in C++)
► organize the way objects are stored in memory

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


► State
► Behavior
► Protected data members (Page 12)
► All of given

130. Public methods of base class can --------- be accessed in its


derived class
► directly (Page 179) rep
► inderectly
► simultaniously
► non of the given

`
AL-JUNAID INSTITUTE GROUP
131. What is true about function templates?
► The compiler generates only one copy of the function template
► The compiler generates a copy of function respective to each type of data (Page
256)
► The compiler can only generate copy for the int type data
► None of the given.

132. 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 ___________).
► scope resolution operator
► dot operator
► null operator
► Operator overloading
133. A template provides a convenient way to make a family of
► variables and data members
► functions and classes(Object-Oriented Programming in C++)
► classes and exceptions
► programs and algorithms

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

► True
► False

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

► Base (Object-Oriented Programming in C++)


► Derived
► Abstract
► virtual

136. In case of multiple inheritance a derived class inherits,

► Only the public member functions of its base classes


► Onlypublic
► Both the public
data data members
members of its base
and member classes of all its base classes
functions
► Data members and member functions of any two base classes

`
AL-JUNAID INSTITUTE GROUP
137. Which of the following is incorrect line regarding function template?

► template<class T>
► template <typename U>
► Class<template T> (Page 257)
► template < class T, class U>
138. Consider a class named Vehicle, which of the following can be the instance of class Vehicle?
i. Car
ii. Computer
iii. Desk
iv. Ahmed
v. Bicycle
vi. Truck
 1,4,5
 2,5,6
 1,2,3,6
 1, 5, 6 Conceptual

139. Consider the code below,


class Fred {
public:
Fred();
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];
...
}
Select the best option,
► Fred a[10]; calls the default constructor 09 times Fred* p =
new Fred[10]; calls the default constructor 10 times
► Produce an error

`
AL-JUNAID INSTITUTE GROUP
► Fred a[10]; calls the default constructor 11 times
Fred* p = new Fred[10]; calls the default constructor 11
times
► Fred a[10]; calls the default constructor 10 times
Fred* p = new Fred[10]; calls the default constructor 10 times

140. When a variable is define as static in a class then all object of this class,

► Have different copies of this variable


► Have same copy of this variable (Page 110)
► Can not access this variable
► None of given

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


►/
►-
►+
► ++ (Page 162)

142. It is sometimes useful to specify a class from which no objects will ever be created.
► True(Object-Oriented Programming in C++)
► False

143. When a subclass specifies an alternative definition for an attribute or method of its superclass, it
is _______ the definition in the superclass.
► overload
► overriding (Page 34)
► copy riding
► none of given

144. The mechanism of selecting function at run time according to the nature of calling object is
called,
► late binding
► static binding
► virtual binding
► None of the given options (Page 227)
145. Dynamic binding means that target function for a call is selected at run time

Which one of the following functions returns the total number of elements in a vector.
► length();
► size(); (Page 318)
► ele();
► veclen();

`
AL-JUNAID INSTITUTE GROUP
146. The main function of scope resolution operator (::) is,
► To define an object
► To define a data member
► To link the definition of an identifier to its declaration Google
► To make a class private

147. When is a constructor called?


► Each time the constructor identifier is used in a program statement
► During the instantiation of a new object (Object-Oriented Programming in C++)
► During the construction of a new class
► At the beginning of any program execution

148. Associativity can be changed in operator overloading.

► True
► False (Page 141)
149. A normal C++ operator that acts in special ways on newly defined data types is said to be

► glorified.
► encapsulated.
► classified.
► overloaded.

150. Which operator can not be overloaded?

► The relation operator ( >= )


► Assignment operator ( = )
► Script operator ( [] )
► Conditional operator (? : ) (Page 141)

151. 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 operator + ( A &obj);
► int + operator(); (Page 143)
► int operator (plus) ();
► A operator(A &obj3);

`
AL-JUNAID INSTITUTE GROUP
152. 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?
► The automatic assignment operator is used
► The copy constructor is used
► Compiler error
► Run-time error

153. A static member function can be called, even when a class is not __________.
► Declared
► Define
► Instantiated
► Called
154. 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.
► Rational_number operator+( Rational_number & obj);
► Rational_number operator+(double& obj);
► Rational_number operator+(Rational_number &obj, double& num);
► operator+(double& obj);
155. What problem(s) may occur when we copy objects without using deep copy constructor?
► Dangling pointer
► Memory Leakage
► All of the given
► System crash
156. __________ provide the facility to access the data member.
► accesser function
► private function
► inline function
► None of the given
157. Constant objects cannot change their state,

`
AL-JUNAID INSTITUTE GROUP
► True
► False
158. The ________ relationship indicates that an object contains other objects.
► None of given
► ‘has-a’
► ‘is-a’
► ‘be-
159. Which one of the following features of OOP is used to derive a class from another?
► Encapsulation
► Polymorphism
► Data hiding
► Inheritance

160. __________ satisfy the condition of polymorphism


► Carbon
► Diamond
► Coal
► all of the given

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


► data hiding
► friend classes
► encapsulation
► inheritance

162. The >= operator can be overloaded.


► True
► False

163. In order to free the memory occupied by the object, we use -------------

`
AL-JUNAID INSTITUTE GROUP
► Constructor
► Destructor
► Shallow Copy
► Deep Copy
164. Which of the following is not an example of multiple inheritances?
► Mermaid
► Woman
► None of the given
► Amphibious Vehicle

165. Static variable can be initialized more than once.


► True
► False

166. A generic class showing all the common attributes and a behavior of other classes represents a
very important feature in oop called --------
► Inheritance
► Encapsulation
► Polymarphism
► Abstraction

167. The parameters given in temple definition other than those used for
mentioning templates types are called
a. Type Parameters
b. Non Type parameters
c. Default Type Parameters
d. None of the given option
168. Which of the following is the correct way to define a template class X?
e. Class < typename T>class X{}
f. Template class C{}
g. Template < typename T> classX{}
h. Typename<class T > class X{}
169. In resolution order of function template, compiler searches for in the end
a. Complete specialization
b. Partial specialization
c. Ordinary function
`
AL-JUNAID INSTITUTE GROUP
d. Generic template
170. may inherit from a complete specialization
a. Partial specialization
b. Complete specialization
c. Ordinary class
d. All of given options
171. Which of the following may inherit form the ordinary class?
a. Class template
b. Partial specialization
c. Complete specialization
d. All of given option

172. Which of the following is a sequence container?


a. Map
b. Vector
c. Set
d. multiset
173. Each _of a template class by default becomes function
template
a. Date member
b. Member function
c. Type parameter
d. Object
174. When we specialize a function template, it is called
a. Function overloading
b. Function overriding
c. Function template overloading
d. Function template overriding
175. Which of the following is NOT an associative container?
a. Set
b. Multiset
c. Map
d. Group
176. A is a pointer which is declared outside the
a. Container, cursor
b. Cursor, container
c. Container, class
d. This, cursor
177. Which of the following are collectively referred to as the first class containers?
a. Associative containers and containers adapters
b. Sequence containers and associative containers
c. Sequence containers and container adapters
`
AL-JUNAID INSTITUTE GROUP
d. None of the given options
178. class is a single class that provides functionality to operate on different type
of data
a. Friend
b. Template
c. Ordinary
d. None of the give options
179. Which of the following can be passed as type argument to template?
a. Primitive type
b. User defined types
c. Both primitive type and user defined types
d. None of the given options
180. Which of the following is known as Dereference operator in C++?
a. +b.
*
c. &
d. ::
181. We can change behavior of template using _
a. Template parameters
b. Function parameters
c. Class Templates
d. none of the given options
182. Which of the following represents partial specialization?
a. Template < int, char >
b. Template < class T, Type t>
c. Template<class T, Class U, int>
d. Template< typename T, class W>
183. When we declare template function as friend of any class, then which of the
followingspecialization(s) of template function also become friend of the class
granting friendship?
a. Explicit
b. Implicit
c. Partial
d. All of the given options
184. In statement “template <class T, class U, int I = 5>” then non-type parameters is

a. Class T
b. Class U
c. int I
d. All of the given option
185. Which of the following is the correct syntax for passing two type argument to
atemplate?

`
AL-JUNAID INSTITUTE GROUP
a. template < type T, type U>
b. template < typename T, typename U>
c. template <type T,U>
d. template Typename < T,U >
186. Which of the following represents complete
specialization?a. Template < int, char >
b. Template < class T, float>
c. Template<class T, Class U , int>
d. Template< class , class W>

187. Which of the following is/are the key component of standard template library?
a. Containers
b. Iterators
c. Algorithm
d. All of the given option
188. Which of the following statement is true about partial specialization?
a. Function templates cannot have partial specialization
b. Class template cannot have partial specialization
c. Both class templates and function template can have partial specialization.
d. None of the given
189. Which of the following is correct code portion to initialize static data member
“value”of int type for class X?
a. Template <class T> X::value =0;
b. Template<class T>int X::value =0;
c. Template<class T> int X < T >::value = 0;
d. Template<class T> X < T >::value =0;
190. When we want to have exactly identical operations on different data type,
are used
a. Function Template
b. Function Overloading
c. Function Overriding
d. None of the given option
191. 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>
192. In case of template specialization, if compiler cannot find required
completespecialization then it searches for some
a. General template
b. Complete template
c. Partial specialization

`
AL-JUNAID INSTITUTE GROUP
d. None of the given
193. Which of the following is the correct code to instantiate the object of given
templatevector class of int type?
Template <class T>
class vector
{
};
a. Vector obj <int>;
b. Vector obj <> int;
c. Vector <int>obj;
c. Vector int obj;

194. Which of the following types of container is NOT provided by standard


TemplateLibrary?
a. Sequence containers
b. Structured containers
c. Associative containers
d. Container adapters
195. A class template
a. Facilitates rescue of class
b. Dose not facilitates reuse of class
c. Does not support generic methods
d. Does not support static members
196. Suppose a template class “test” has a static data members, how many copies of
thisstatic data member will be created when template class is instantiated by
writing following line of C++ code?
Test <char>x,y,z
a. Zero
b. One Correct
c. Two
197. STL stands for:
a. Stack Template Library
b. Standard Template Library
c. Structured Template Library
d. Secure Template Library
198. Which of the following is not a sequence container?
a. Vector
b. Dequec. Map
d. List
199. Suppose a template class “test” has a static data members, how many copies of thisstatic
data member will be created when template class is instantiated by writing following line of
C++ code?
`
AL-JUNAID INSTITUTE GROUP
Test <int>x; Test <char>y;
a. Zero
b. Onec. Two
d. Three
200. Suppose we have a template class “Test” which have a static data member “data”which is
initialized with 0. What will be output when following code is written inmain() function for
given class?
Test<int> a, b;a.data = 5;
b.data = 7; cout<<a.data;
a. 0
b. 1c. 5
d. 7 Correct
201. In resolution order, highest priority is given to in template specialization.
a. General template
b. Complete specialization
c. Partial specialization
d. None of the given options
202. Which of the following is a constrained version of some first-class container?
a. Sequence containers
b. Associative containers
c. Container Adapter
d. None of the given options

`
AL-JUNAID INSTITUTE GROUP

`
AL-JUNAID INSTITUTE GROUP

`
CS304- Object Oriented Programming
LATEST SOLVED MCQS JAN 28,2011
FROM FINALTERM PAPERS

MC100401285 [email protected] [email protected] PSMD01

FINALTERM EXAMINATION
14 Feb, 2011
CS304- Object Oriented Programming (Session - 3)

Question No: 1 ( Marks: 1 ) - Please choose one


Which of the following causes run time binding?

► Declaring object of abstract class


► Declaring pointer of abstract class
► Declaring overridden methods as non-virtual (Page 226)
► None of the given

Question No: 2 ( Marks: 1 ) - Please choose one


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?

► Templates (Page 256)


► Overloading
► Data hiding
► Encapsulation

Question No: 3 ( Marks: 1 ) - Please choose one


A copy constructor is invoked when

► a function do not returns by value.


► an argument is passed by value. (Page 78)
► a function returns by reference.
► an argument is passed by reference.

Question No: 4 ( Marks: 1 ) - Please choose one


Like template functions, a class template may not handle all the types successfully.

► True (Page 258)


► False

1
Question No: 6 ( Marks: 1 ) - Please choose one
A class template may inherit from another class template.

► True (Page 288)


► False

Question No: 7 ( Marks: 1 ) - Please choose one


By default the vector data items are initialized to ____
►0 Click here for detail
► 0.0
►1
► null

Question No: 8 ( Marks: 1 ) - Please choose one


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

► specialization
► inheritance (Page 216)
► abstraction
► composition

Question No: 9 ( Marks: 1 ) - Please choose one


Which of the following is/are advantage[s] of generic programming?
► Reusability
► Writability
► Maintainability
► All of given (Page 256)

Question No: 10 ( Marks: 1 ) - Please choose one


Template functions use _________ than ordinary functions.

► Greater Memory
► Lesser Memory
► Equal Memory
► None of the given options

Question No: 11 ( Marks: 1 ) - Please choose one


Non Template Friend functions of a class are friends of ________instance/s of that class.

► All Click here for detail


► One specific
► All instances of one date type
► None of the given options
2
Question No: 12 ( Marks: 1 ) - Please choose one
A copy constructor is invoked when
► a function do not returns by value.
► an argument is passed by value. (Page 78)
► a function returns by reference.
► an argument is passed by reference.

Question No: 13 ( Marks: 1 ) - Please choose one


A pointer to a base class can point to objects of a derived class.

► True Click here for detail


► False

Question No: 14 ( Marks: 1 ) - Please choose one


A template argument is preceded by the keyword ________.
► vector
► class Click here for Detail
► template
► type*

Question No: 15 ( Marks: 1 ) - Please choose one


Which one of the following terms must relate to polymorphism?
► Static allocation
► Static typing
► Dynamic binding (Page 239)
► Dynamic allocation

Question No: 16 ( Marks: 1 ) - Please choose one


Multiple inheritance can be of type

► Public
► Private
► Protected
► All of the given Click here for detail

Question No: 17 ( Marks: 1 ) - Please choose one


Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access
► public members of Derv. (Object-Oriented Programming in C++)
► protected members of Derv.
► private members of Derv.
► protected members of Base.

3
Question No: 18 ( Marks: 1 ) - Please choose one
A copy constructor is invoked when
► a function do not returns by value.
► an argument is passed by value. (Page 78) (rep)
► a function returns by reference.
► an argument is passed by reference.

Question No: 19 ( Marks: 1 ) - Please choose one


A function call is resolved at run-time in___________
► non-virtual member function.
► virtual member function. (Page 239)
► Both non-virtual member and virtual member function.
► None of given

Question No: 20 ( Marks: 1 ) - Please choose one


Two important STL associative containers are _______ and _______.

► set,map (Object-Oriented Programming in C++)


► sequence,mapping
► setmet,multipule
► sit,mat

Question No: 21 ( Marks: 1 ) - Please choose one


An abstract class is useful when,

► We do not derive any class from it.


► There are multiple paths from one derived class to another.
► We do not want to instantiate its object. (Object-Oriented Programming in C++)
► You want to defer the declaration of the class.

Question No: 22 ( Marks: 1 ) - Please choose one


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

► Reusability
► Writability
► Maintainability
► All of given (Page 256) rep

Question No: 23 ( Marks: 1 ) - Please choose one


By default the vector data items are initialized to ____
►0 Click here for Detail rep
► 0.0
►1
► null
4
Question No: 24 ( Marks: 1 ) - Please choose one
Suppose you create an uninitialized vector as follows:

vector<int> evec;
After adding the statment,
evec.push_back(21);
what will happen?
► The following statement will add an element to the start (the back) of evec and will initialize it with the
value 21.
► The following statement will add an element to the center of evec and will reinitialize it with the value
21.
► The following statement will delete an element to the end (the back) of evec and will reinitialize it with
the value 21.
► The following statement will add an element to the end (the back) of evec and initialize it with the
value 21. Click here for detail

Question No: 25 ( Marks: 1 ) - Please choose one


Default constructor is such constructor which either has no ---------or if it has some parameters these have -----
--- values

► Parameter, temporary
► Null, Parameter
► Parameter, default (Page 75)
► non of the given

Question No: 26 ( Marks: 1 ) - Please choose one


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?
► Templates (Page 256) rep
► Overloading
► Data hiding
► Encapsulation

Question No: 27 ( Marks: 1 )


Describe the way to declare a template class as a friend of any class.

Question No: 28 ( Marks: 1 )


Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete, while
classes like Sphere and Cube would normally be abstract.
► True Click here for detail
► False

5
Question No: 29 ( Marks: 1 )
In order to define a class template, the first line of definition must be:

► template <typename T> (Page 257)


► typename <template T>
► Template Class <ClassName>
► Class <Template T>

Question No: 30 ( Marks: 1 )


In case of multiple inheritance a derived class inherits,

► Only the public member functions of its base classes


► Only the public data members of its base classes
► Both public data members and member functions of all its base classes
Click here for detail
► Data members and member functions of any two base classes

Question No: 31 ( Marks: 1 )


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

► specialization
► inheritance (Page 216) rep
► abstraction
► composition

Question No: 32 ( Marks: 1 )


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?

► Templates (Page 256) rep


► Overloading
► Data hiding
► Encapsulation

6
FINALTERM EXAMINATION
Spring 2010
CS304- Object Oriented Programming

Question No: 1 ( Marks: 1 ) - Please choose one


A template argument is preceded by the keyword ________.

► vector
► class (Object-Oriented Programming in C++)
► template
► type*

Question No: 2 ( Marks: 1 ) - Please choose one


Which of the following causes run time binding?

► Declaring object of abstract class


► Declaring pointer of abstract class
► Declaring overridden methods as non-virtual (Page 226)
► None of the given

Question No: 3 ( Marks: 1 ) - Please choose one


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

► True (Object-Oriented Programming in C++)


► False

Question No: 4 ( Marks: 1 ) - Please choose one


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?

► Templates (Page 256) rep


► Overloading
► Data hiding
► Encapsulation

Question No: 5 ( Marks: 1 ) - Please choose one


Identify the correct way of declaring an object of user defined template class A for char type members?

► A< char > obj; (Object-Oriented Programming in C++)


► <char>A obj;
► A obj<char>;
► Obj <char> A;
7
Question No: 6 ( Marks: 1 ) - Please choose one
The user must define the operation of the copy constructor.

► True Click here for detail


► False

Question No: 7 ( Marks: 1 ) - Please choose one


Template functions use _________ than ordinary functions.

► Greater Memory
► Lesser Memory
► Equal Memory
► None of the given options

Question No: 8 ( Marks: 1 ) - Please choose one


The find() algorithm

► finds matching sequences of elements in two containers.


► finds a container that matches a specified container.
► takes iterators as its first two arguments. (Object-Oriented Programming in C++)
► takes container elements as its first two arguments.

Question No: 9 ( Marks: 1 ) - Please choose one


Compiler performs ________ type checking to diagnose type errors,

► Static (Page 261)


► Dynamic
► Bound
► Unbound

Question No: 10 ( Marks: 1 ) - Please choose one


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

► Reusability
► Writability
► Maintainability
► All of given (Page 256) rep

Question No: 11 ( Marks: 1 ) - Please choose one


Vectors contain contiguous elements stored as a[an] ___.

► variable
► array (Page 306)
► function
► datatype
8
Question No: 12 ( Marks: 1 ) - Please choose one
Suppose you create an uninitialized vector as follows:

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

► The following statement will add an element to the start (the back) of evec and will initialize it with the
value 21.
► The following statement will add an element to the center of evec and will reinitialize it with the value
21.
► The following statement will delete an element to the end (the back) of evec and will reinitialize it with
the value 21.
► The following statement will add an element to the end (the back) of evec and initialize it with the
value 21. Click here for detail

Question No: 13 ( Marks: 1 ) - Please choose one


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

► data can be quickly inserted or deleted at any arbitrary location.


► data can be inserted or deleted at any arbitrary location, but the process is relatively slow.
(Object-Oriented Programming in C++)
► data can not be quickly inserted or deleted at either end.
► data can be inserted or deleted at either end, but the process is relatively slow.

Question No: 14 ( Marks: 1 ) - Please choose one


Algorithms can only be implemented using STL containers.

► True
► False (Object-Oriented Programming in C++)

Question No: 15 ( Marks: 1 ) - Please choose one


What is a class?

► A class is a section of computer memory containing objects.


► A class is a section of the hard disk reserved for object oriented programs
► A class is the part of an object that contains the variables.
► A class is a description of a kind of object. Click here for detail

9
Question No: 16 ( Marks: 1 ) - Please choose one
Inheritance is a way to

► organize data.
► pass arguments to objects of classes.
► add features to existing classes without rewriting them. (Page 27)
► improve data-hiding and encapsulation.

Question No: 17 ( Marks: 1 ) - Please choose one


We can use "this" pointer in the constructor in the body and even in the initialization list of any class if we are
careful,
► True Click here for detail
► False

Question No: 18 ( Marks: 1 ) - Please choose one


________ and ______ methods may not be declared abstract.

► private,static Click here for detail


► private,public
► static,public
► none of given

Question No: 19 ( Marks: 1 ) - Please choose one


Default constructor is such constructor which either has no ---------or if it has some parameters these have -------- values

► Parameter, temporary
► Null, Parameter
► Parameter, default (Page 75) rep
► non of the given

Question No: 20 ( Marks: 1 ) - Please choose one


Public methods of base class can --------- be accessed in its derived class

► directly (Page 179)


► inderectly
► simultaniously
► non of the given

Question No: 21 ( Marks: 1 ) - Please choose one


The type that is used to declare a reference or pointer is called its ---------

► default type
► static type (Page 185)
► abstract type
► reference type
10
Question No: 22 ( Marks: 1 ) - Please choose one
------------- members are somewhere between public and private members. They are used in inheritance

► protected (Page 187)


► public
► private
► global

Question No: 23 ( Marks: 1 ) - Please choose one


Which of these are examples of error handling techniques?

► Abnormal Termination
► Graceful Termination
► Return the illegal
► all of the given (Page 329)

Question No: 24 ( Marks: 1 ) - Please choose one


----------------- follow try block to catch the object thrown

► catch block (Page 333)


► throw block
► main block
► non of the given

Question No: 25 ( Marks: 1 ) - Please choose one


Graphical representation of the classes and objects is called object model it shows -------

► Class Name only


► Class Name and attributes
► Relationships of the objects and classes
► all of the given Click here for detail

Question No: 26 ( Marks: 1 ) - Please choose one


Destructor can be overloaded

► True
► False (Page 92)

FINALTERM EXAMINATION
Spring 2010
CS304- Object Oriented Programming (Session - 3)

11
Question No: 1 ( Marks: 1 ) - Please choose one
Which one of the following terms must relate to polymorphism?
► Static allocation
► Static typing
► Dynamic binding (Page 239)
► Dynamic allocation

Question No: 2 ( Marks: 1 ) - Please choose one


Which of the following causes run time binding?

► Declaring object of abstract class


► Declaring pointer of abstract class
► Declaring overridden methods as non-virtual (Page 226)
► None of the given

Question No: 3 ( Marks: 1 ) - Please choose one


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?

► Templates (Page 256) rep


► Overloading
► Data hiding
► Encapsulation

Question No: 4 ( Marks: 1 ) - Please choose one


Which of the following is the best approach to implement generic algorithms with minimum number of coding
lines?

► Templates (Page 256)


► Overloading
► Overriding
► Friend function/class

Question No: 5 ( Marks: 1 ) - Please choose one


Like template functions, a class template may not handle all the types successfully.

► True (Page 258) rep


► False

Question No: 6 ( Marks: 1 ) - Please choose one


A class template may inherit from another class template.

► True (Page 288) rep


► False

12
Question No: 7 ( Marks: 1 ) - Please choose one
Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access

► public members of Derv. (Object-Oriented Programming in C++) rep


► protected members of Derv.
► private members of Derv.
► protected members of Base.

Question No: 8 ( Marks: 1 ) - Please choose one


A copy constructor is invoked when

► a function do not returns by value.


► an argument is passed by value. (Page 78) rep
► a function returns by reference.
► an argument is passed by reference.

Question No: 9 ( Marks: 1 ) - Please choose one


Each try block can have ______ no. of catch blocks.

►1
►2
►3
► As many as necessary. Click here for detail
A single try block can have multiple catch blocks but only one finally block.

Question No: 10 ( Marks: 1 ) - Please choose one


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()
{
DocElement * p = new Paragraph();

13
p->Print();
}
When you run this program, it will print out a single line to the console output.

What will be in that line?

Select one correct answer from the following list:

► Generic element
► Heading element
► Paragraph element
► Nothing will be printed.

Question No: 11 ( Marks: 1 ) - Please choose one


Suppose we have two derived classes from a single class, can we write a method with same name in
both these derived classes? Choose the best option.
► No
► Only if the two classes have the same name (Page 204)
► Only if the main program does not declare both kinds
► Yes

Question No: 12 ( Marks: 1 ) - Please choose one


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.

► True
► False (Object-Oriented Programming in C++)
(the function invocation is resolved at compile time)

Question No: 13 ( Marks: 1 ) - Please choose one


Considering the resolution order in which Considering the resolution order in which compiler search
for functions in a program; the first priority is given to; the first priority is given to,

► general template
► partial specialization
► complete specialization
► ordinary function (Page 287)

Question No: 14 ( Marks: 1 ) - Please choose one


Vectors contain contiguous elements stored as a[an] ___.

► variable
► array (Page 306) rep
► function
► datatype
14
Question No: 15 ( Marks: 1 ) - Please choose one
By default the vector data items are initialized to ____

►0 Click here for detail rep


► 0.0
►1
► null

Question No: 16 ( Marks: 1 ) - Please choose one


One purpose of an iterator in the STL is to connect algorithms and containers.

► True (Object-Oriented Programming in C++)


► False

Question No: 17 ( Marks: 1 ) - Please choose one


Algorithms can only be implemented using STL containers.

► True
► False (Object-Oriented Programming in C++) rep

Question No: 18 ( Marks: 1 ) - Please choose one


In ________, a base class can be replaced by its derived class,

► Sub-typing (Page 31)


► Super-typing
► Multiple-typing
► Restricted-typing

Question No: 19 ( Marks: 1 ) - Please choose one


this pointer does not point to current object of any class,
► True
► False Click here for detail
The this pointer is a hidden pointer inside every class member function that points to the class object
the member function is working with.

Question No: 20 ( Marks: 1 ) - Please choose one


Which of the following operator(s) take(s) one or no argument if overloaded?

► ++ (Page 162)
►-
►+
► All of the given

15
Question No: 21 ( Marks: 1 ) - Please choose one
Which of the following operators can not be overloaded?

► Scope resolution operator ( :: ) (Page 141)


► Insertion operator ( << )
► Extraction operator ( >> )
► The relation operator ( > )

Question No: 22 ( Marks: 1 ) - Please choose one


The type that is used to declare a reference or pointer is called its ---------

► default type
► static type (Page 185) rep
► abstract type
► reference type

Question No: 23 ( Marks: 1 ) - Please choose one


------------- members are somewhere between public and private members. They are used in inheritance
► protected (Page 187) rep
► public
► private
► global

Question No: 24 ( Marks: 1 ) - Please choose one


Which of these are examples of error handling techniques ?
► Abnormal Termination
► Graceful Termination
► Return the illegal
► all of the given (Page 329)

Question No: 25 ( Marks: 1 ) - Please choose one


_______ “is a” relationship

► Inheritance (Page 25)


► Polymarphism
► abstraction
► encapsulation

Question No: 26 ( Marks: 1 ) - Please choose one


Graphical representation of the classes and objects is called object model it shows -------

► Class Name only


► Class Name and attributes
► Relationships of the objects and classes
► all of the given Click here for detail rep
16
FINALTERM EXAMINATION
Spring 2010
CS304- Object Oriented Programming (Session - 4)

Question No: 1 ( Marks: 1 ) - Please choose one


Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete, while
classes like Sphere and Cube would normally be abstract.
► True Click here for detail rep
► False

Question No: 2 ( Marks: 1 ) - Please choose one


Virtual functions allow you to

► create an array of type pointer-to-base class that can hold pointers to derived classes.
► create functions that can never be accessed.
► group objects of different classes so they can all be accessed by the same function code.
► use the same function call to execute member functions of objects from different
classes (Object-Oriented Programming in C++)

Question No: 3 ( Marks: 1 ) - Please choose one


.
► True Click here for detail rep
► False

Question No: 4 ( Marks: 1 ) - Please choose one


A copy constructor is invoked when

► a function do not returns by value.


► an argument is passed by value. (Page 78) rep
► a function returns by reference.
► an argument is passed by reference.

Question No: 5 ( Marks: 1 ) - Please choose one


Each try block can have ______ no. of catch blocks.

►1
►2
►3
► As many as necessary. Click here for detail rep

17
Question No: 6 ( Marks: 1 ) - Please choose one
Non Template Friend functions of a class are friends of ________instance/s of

► All Click here for detail rep


► One specific
► All instances of one date type
► None of the given options

Question No: 7 ( Marks: 1 ) - Please choose one


Template functions use _________ than ordinary functions.

► Greater Memory
► Lesser Memory
► Equal Memory
► None of the given options

Question No: 8 ( Marks: 1 ) - Please choose one


The find() algorithm

► finds matching sequences of elements in two containers.


► finds a container that matches a specified container.
► takes iterators as its first two arguments. (Object-Oriented Programming in C++)
► takes container elements as its first two arguments.

Question No: 9 ( Marks: 1 ) - Please choose one


The copy() algorithm returns an iterator to

► the last element copied from.


► the last element copied to.
► the element one past the last element copied from.
► the element one past the last element copied to. (Object-Oriented Programming in
C++)

Question No: 10 ( Marks: 1 ) - Please choose one


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.

► 11 for v and 3 for w.


► 0 for v and 0 for w.
► 0 for v and 3 for w.
► 3 for v and 11 for w. (Object-Oriented Programming in C++)

18
Question No: 11 ( Marks: 1 ) - Please choose one
Which is not the Advantage of inheritance?

► providing class growth through natural selection. (Object-Oriented Programming in


C++)
► facilitating class libraries.
► avoiding the rewriting of code.
► providing a useful conceptual framework.

Question No: 12 ( Marks: 1 ) - Please choose one


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()
{
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?

Select one correct answer from the following list:

► Generic element
► Heading element
► Paragraph element
► Nothing will be printed.

19
Question No: 13 ( Marks: 1 ) - Please choose one
Which type of inheritance is being represented by the following statement,
class X : public A, public B { ... ... };

► Single inheritance
► Multiple inheritance (Page 41)
► Double inheritance
► None of the given options

Question No: 14 ( Marks: 1 ) - Please choose one


When we write a class template the first line must be:

► template < class class_name>


► template < class data_type>
► template < class T > (Page 257)
Here T can be replaced with any name but it is preferable.
► class class-name()
class template<class_name>

Question No: 15 ( Marks: 1 ) - Please choose one


Function templates should be used where code and behavior must be identical.
► True (Page 262)
► False

Question No: 16 ( Marks: 1 ) - Please choose one


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

► Reusability
► Writability
► Maintainability
► All of given (Page 256) rep

Question No: 17 ( Marks: 1 ) - Please choose one


The specialization pattern <T*> after the name says that this specialization is to be used for every,
► data type
► meta type
► virtual type
► pointer type (Page 286)

Question No: 18 ( Marks: 1 ) - Please choose one


A range is often supplied to an algorithm by two _______ values.
► italic
► iteration (Object-Oriented Programming in C++)
► iterator
► None of given
20
Question No: 19 ( Marks: 1 ) - Please choose one
Which of the following is an integral part of an object?

► State
► Behavior
► Unique identity
► All of the given (Page 12)

Question No: 20 ( Marks: 1 ) - Please choose one


Consider the following statement

Cupboard has books


What is the relationship between Cupboard and books?

► Composition
► Aggregation
► Inheritance
► None of the given options

Question No: 21 ( Marks: 1 ) - Please choose one


Which sentence clearly defines an object?

► one instance of a class. (Page 23)


► another word for a class.
► a class with static methods.
► a method that accesses class attributes.

Question No: 22 ( Marks: 1 ) - Please choose one


___________, 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.

► Friendship is one way only Click here for detail


► Friendship is two way only
► NO Friendship between classes
► Any kind of friendship

Question No: 23 ( Marks: 1 ) - Please choose one


The statement objA=objB; will cause a compiler error if the objects are of different classes.

► True
► False (Object-Oriented Programming in C++)

21
Question No: 24 ( Marks: 1 ) - Please choose one
Consider the call given below of an overloaded operator "+",
Rational_number_1 + Rational_number_2
Where Rational_number_1 and Rational_number_2 are the two objects of Rational_number class (a
user defined class). Identify which of the above two objects will be passed as an argument to the
overloaded operator function?

► Rational_number_1
► Rational_number_2
► Both Rational_number_1 & Rational_number_2
► any of the two objects, randomly

Question No: 25 ( Marks: 1 ) - Please choose one


If a class D has been derived using protected inheritance from class B (If B is a protected base and D is
derived class) then public and protected members of B -------- accessed by member functions and friends of
class D and classes derived from D
► can be Click here for detail
► cannot be
► does restirct to be
► not given

Question No: 26 ( Marks: 1 ) - Please choose one


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

► specialization
► inheritance (Page 216) rep
► abstraction
► composition

FINAL TERM EXAMINATION


SPRING 2010

Question No: 1 ( Marks: 1 ) - Please choose one


Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete, while
classes like Sphere and Cube would normally be abstract.
► True Click here for detail rep
► False

22
Question No: 2 ( Marks: 1 ) - Please choose one
Each try block can have ______ no. of catch blocks.
►1
►2
►3
► As many as necessary. Click here detail

Question No: 3 ( Marks: 1 ) - Please choose one


Function templates should be used where code and behavior must be identical.
► True (Page 262)
► False

Question No: 4 ( Marks: 1 ) - Please choose one


Consider the following statement
Cupboard has books
What is the relationship between Cupboard and books?
► Composition
► Aggregation
► Inheritance
► None of the given options

Question No: 5 ( Marks: 1 ) - Please choose one


Identify the correct way of declaring an object of user defined template class A for char type members?
► A< char > obj; (Object-Oriented Programming in C++)
► <char>A obj;
► A obj<char>;
► Obj <char> A;

Question No: 6 ( Marks: 1 ) - Please choose one


The user must define the operation of the copy constructor.
► True Click here for detail
► False

Question No: 7 ( Marks: 1 ) - Please choose one


Default constructor is such constructor which either has no ---------or if it has some parameters these have
-------- values
► Parameter, temporary
► Null, Parameter
► Parameter, default (Page 75) rep
► non of the given

Question No: 8 ( Marks: 1 ) - Please choose one


The type that is used to declare a reference or pointer is called its ---------
► default type
► static type (Page 185)
► abstract type
► reference type
23
Question No: 9 ( Marks: 1 ) - Please choose one
How the information hidden within an object can be accessed?
► Through its interface
► Through its private data members
► Through its private member functions
► Through both public and private members

Question No: 10 ( Marks: 1 ) - Please choose one


The sub-object’s life is not dependant on the life of master class in __________.
► Separation
► Composition
► Aggregation (Page 134)
► None of the given

Question No: 11 ( Marks: 1 ) - Please choose one


Encapsulation means
Select correct option:
►Extending the behaviour of class in another class
►Data and behaviour are tightly coupled within an entity (Page 16)
►One entity takes all the attributes and operations of the other
►Taking out the common features and put those in a separate class

Question No: 12 ( Marks: 1 ) - Please choose one


Algorithms can only be implemented using STL containers.

► True
► False (Object-Oriented Programming in C++) rep

Question No: 13 ( Marks: 1 ) - Please choose one


When we write a class template the first line must be:

► template < class class_name>


► template < class data_type>
► template < class T > (Page 257) rep
Here T can be replaced with any name but it is preferable.
► class class-name()
class template<class_name>

Question No: 14 ( Marks: 1 ) - Please choose one


An STL container can not be used to,

► hold objects of class employee.


► store elements in a way that makes them quickly accessible.
► compile c++ programs. (Object-Oriented Programming in C++)
► organize the way objects are stored in memory

24
Question No: 15 ( Marks: 1 ) - Please choose one
___________, 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.
► Friendship is one way only Click here for detail
► Friendship is two way only
► NO Friendship between classes
► Any kind of friendship

Question No: 16 ( Marks: 1 ) - Please choose one


Which of the following may not be an integral part of an object?
► State
► Behavior
► Protected data members (Page 12)
► All of given

Question No: 17 ( Marks: 1 ) - Please choose one


Public methods of base class can --------- be accessed in its derived class
► directly (Page 179) rep
► inderectly
► simultaniously
► non of the given

Question No: 18 ( Marks: 1 ) - Please choose one


If a class D has been derived using protected inheritance from class B (If B is a protected base and D is
derived class) then public and protected members of B -------- accessed by member functions and friends
of class D and classes derived from D
► can be Click here for detail
► cannot be
► does restirct to be
► not given

Question No: 19 ( Marks: 1 ) - Please choose one


What is true about function templates?
► The compiler generates only one copy of the function template
► The compiler generates a copy of function respective to each type of data (Page 256)
► The compiler can only generate copy for the int type data
► None of the given.

Question No: 20 ( Marks: 1 ) - Please choose one


Which of the following is an integral part of an object?
► State
► Behavior
► Unique identity
► All of the given (Page 12) rep

25
Question No: 21 ( Marks: 1 ) - Please choose one
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 ___________).
► scope resolution operator
► dot operator
► null operator
► Operator overloading Click here for detail

FINALTERM EXAMINATION
Fall 2009
CS304- Object Oriented Programming (Session - 4)

Question No: 1 ( Marks: 1 ) - Please choose one


A template provides a convenient way to make a family of
► variables and data members
► functions and classes (Object-Oriented Programming in C++)
► classes and exceptions
► programs and algorithms

Question No: 2 ( Marks: 1 ) - Please choose one


Which one of the following terms must relate to polymorphism?

► Static allocation
► Static typing
► Dynamic binding (Page 239) rep
► Dynamic allocation

Question No: 3 ( Marks: 1 ) - Please choose one


What is true about function templates?

► The compiler generates only one copy of the function template


► The compiler generates a copy of function respective to each type of data (Page 256)
rep
► The compiler can only generate copy for the int type data
► None of the given.

Question No: 4 ( Marks: 1 ) - Please choose one


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?
► Templates (Page 256) rep
► Overloading
► Data hiding
► Encapsulation
26
Question No: 5 ( Marks: 1 ) - Please choose one
template <>
class Vector<char*> { }

This is an example of partial specialization.

► True (Page 287)


► False

Question No: 6 ( Marks: 1 ) - Please choose one


Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete, while
classes like Sphere and Cube would normally be abstract.
► True Click here for detail rep
► False

Question No: 7 ( Marks: 1 ) - Please choose one


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.

► True
► False

Question No: 8 ( Marks: 1 ) - Please choose one


Assume a class Derv that is privately derived from class Base. An object of class Derv located in main()
can access

► public members of Derv. (Object-Oriented Programming in C++) rep


► protected members of Derv.
► private members of Derv.
► protected members of Base.

Question No: 9 ( Marks: 1 ) - Please choose one


In order to define a class template, the first line of definition must be:

► template <typename T> (Page 257) rep


► typename <template T>
► Template Class <ClassName>
► Class <Template T>

27
Question No: 10 ( Marks: 1 ) - Please choose one
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.

► Base (Object-Oriented Programming in C++)


► Derived
► Abstract
► virtual

Question No: 11 ( Marks: 1 ) - Please choose one


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 ___________).

► scope resolution operator


► dot operator
► null operator
► Operator overloading Click here for detail

Question No: 12 ( Marks: 1 ) - Please choose one


Non Template Friend functions of a class are friends of ________instance/s of that class.

► All Click here for detail


► One specific
► All instances of one date type
► None of the given options

Question No: 13 ( Marks: 1 ) - Please choose one


The find() algorithm

► finds matching sequences of elements in two containers.


► finds a container that matches a specified container.
► takes iterators as its first two arguments. (Object-Oriented Programming in C++) rep
► takes container elements as its first two arguments.

Question No: 14 ( Marks: 1 ) - Please choose one


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.

► 11 for v and 3 for w.


► 0 for v and 0 for w.
► 0 for v and 3 for w.
► 3 for v and 11 for w. (Object-Oriented Programming in C++) rep
28
Question No: 15 ( Marks: 1 ) - Please choose one
Which of the following may not be an integral part of an object?

► State
► Behavior
► Protected data members (Page 12)
► All of given

Question No: 16 ( Marks: 1 ) - Please choose one


Which is not the Advantage of inheritance?

► providing class growth through natural selection. (Object-Oriented Programming in


C++) rep
► facilitating class libraries.
► avoiding the rewriting of code.
► providing a useful conceptual framework.

Question No: 17 ( Marks: 1 ) - Please choose one


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

2class Heading : public DocElement


{
public:
void Print() { cout << "Heading element"; }
};

3class Paragraph : public DocElement


{
public:
void Print() { cout << "Paragraph element"; }
};

void main()
{
DocElement * p = new Paragraph();

p->Print();
}

When you run this program, it will print out a single line to the console output.
29
What will be in that line?

Select one correct answer from the following list:

► Generic element
► Heading element
► Paragraph element
► Nothing will be printed.

Question No: 18 ( Marks: 1 ) - Please choose one


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.

► True
► False (Object-Oriented Programming in C++)
(the function invocation is resolved at compile time)
Question No: 19 ( Marks: 1 ) - Please choose one
In case of multiple inheritance a derived class inherits,

► Only the public member functions of its base classes


► Only the public data members of its base classes
► Both public data members and member functions of all its base classes
Click here for detail
► Data members and member functions of any two base classes

Question No: 20 ( Marks: 1 ) - Please choose one


When we write a class template the first line must be:

► template < class class_name>


► template < class data_type>
► template < class T > (Page 257) rep
Here T can be replaced with any name but it is preferable.
► class class-name()
class template<class_name>

Question No: 21 ( Marks: 1 ) - Please choose one


Which of the following is incorrect line regarding function template?

► template<class T>
► template <typename U>
► Class<template T> (Page 257)
► template < class T, class U>

30
Question No: 22 ( Marks: 1 ) - Please choose one
An STL container can not be used to,

► hold objects of class employee.


► store elements in a way that makes them quickly accessible.
► compile c++ programs. (Object-Oriented Programming in C++) rep
► organize the way objects are stored in memory

Question No: 23 ( Marks: 1 ) - Please choose one


Algorithms can only be implemented using STL containers.

► True
► False (Object-Oriented Programming in C++) rep

Question No: 24 ( Marks: 1 ) - Please choose one


Consider a class named Vehicle, which of the following can be the instance of class Vehicle?
1. Car
2. Computer
3. Desk
4. Ahmed
5. Bicycle
6. Truck
► 1, 4, 5
► 2, 5, 6
► 1, 2, 3, 6
► 1, 5, 6 (correct)

Question No: 25 ( Marks: 1 ) - Please choose one


Consider the code below,
class Fred {
public:
Fred();
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];
...
}
Select the best option,
► Fred a[10]; calls the default constructor 09 times
Fred* p = new Fred[10]; calls the default constructor 10 times
► Produce an error
31
► Fred a[10]; calls the default constructor 11 times
Fred* p = new Fred[10]; calls the default constructor 11 times
► Fred a[10]; calls the default constructor 10 times
Fred* p = new Fred[10]; calls the default constructor 10 times Click here for detail

Question No: 26 ( Marks: 1 ) - Please choose one


When a variable is define as static in a class then all object of this class,

► Have different copies of this variable


► Have same copy of this variable (Page 110)
► Can not access this variable
► None of given

Question No: 27 ( Marks: 1 ) - Please choose one


The life of sub object is dependant on the life of master class in _____________.

► Separation
► Composition (Page 53)
► Aggregation
► None of the given

Question No: 28 ( Marks: 1 ) - Please choose one


___________, 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.

► Friendship is one way only Click here for detail


► Friendship is two way only
► NO Friendship between classes
► Any kind of friendship

Question No: 29 ( Marks: 1 ) - Please choose one


Which of the following operators always takes no argument if overloaded?
►/
►-
►+
► ++ (Page 162)

Question No: 30 ( Marks: 1 ) - Please choose one


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

► specialization
► inheritance (Page 216) rep
► abstraction
► composition
32
FINALTERM EXAMINATION
Fall 2009
CS304- Object Oriented Programming (Session - 1)

Question No: 1 ( Marks: 1 ) - Please choose one


Which one of the following terms must relate to polymorphism?
► Static allocation
► Static typing
► Dynamic binding (Page 239) rep
► Dynamic allocation

Question No: 2 ( Marks: 1 ) - Please choose one


Multiple inheritance can be of type
► Public
► Private
► Protected
► All of the given Click here for detail

Question No: 3 ( Marks: 1 ) - Please choose one


When a subclass specifies an alternative definition for an attribute or method of its superclass, it is _______ the
definition in the superclass.
► overload
► overriding (Page 34)
► copy riding
► none of given

Question No: 4 ( Marks: 1 ) - Please choose one


Like template functions, a class template may not handle all the types successfully.
► True (Page 258) rep
► False

Question No: 5 ( Marks: 1 ) - Please choose one


It is sometimes useful to specify a class from which no objects will ever be created.
► True (Object-Oriented Programming in C++)
► False

Question No: 6 ( Marks: 1 ) - Please choose one


Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access
► public members of Derv. (Object-Oriented Programming in C++) rep
► protected members of Derv.
► private members of Derv.
► protected members of Base.
33
Question No: 7 ( Marks: 1 ) - Please choose one
A pointer to a base class can point to objects of a derived class.
► True Click here for detail
► False

Question No: 8 ( Marks: 1 ) - Please choose one


A copy constructor is invoked when
► a function do not returns by value.
► an argument is passed by value. (Page 78) rep
► a function returns by reference.
► an argument is passed by reference.

Question No: 9 ( Marks: 1 ) - Please choose one


A function call is resolved at run-time in___________
► non-virtual member function.
► virtual member function. (Page 239) rep
► Both non-virtual member and virtual member function.
► None of given

Question No: 10 ( Marks: 1 ) - Please choose one


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 ___________).
► scope resolution operator
► dot operator
► null operator
► Operator overloading Click here for detail

Question No: 11 ( Marks: 1 ) - Please choose one


Each try block can have ______ no. of catch blocks.

►1
►2
►3
► As many as necessary. Click here for detail rep

Question No: 12 ( Marks: 1 ) - Please choose one


Two important STL associative containers are _______ and _______.

► set,map (Object-Oriented Programming in C++) rep


► sequence,mapping
► setmet,multipule
► sit,mat

34
Question No: 13 ( Marks: 1 ) - Please choose one
The mechanism of selecting function at run time according to the nature of calling object is called,
► late binding
► static binding
► virtual binding
► None of the given options (Page 227)
Dynamic binding means that target function for a call is selected at run time

Question No: 14 ( Marks: 1 ) - Please choose one


An abstract class is useful when
► We do not derive any class from it.
► There are multiple paths from one derived class to another.
► We do not want to instantiate its object. (Object-Oriented Programming in C++) rep
► You want to defer the declaration of the class.

Question No: 15 ( Marks: 1 ) - Please choose one


Which of the following is incorrect line regarding function template?
► template<class T>
► template <typename U>
► Class<template T> (Page 257) rep
► template < class T, class U>

Question No: 16 ( Marks: 1 ) - Please choose one


Which of the following is/are advantage[s] of generic programming?
► Reusability
► Writability
► Maintainability
► All of given (Page 256) rep

Question No: 17 ( Marks: 1 ) - Please choose one


By default the vector data items are initialized to ____
►0 Click here for detail rep
► 0.0
►1
► null

Question No: 18 ( Marks: 1 ) - Please choose one


Which one of the following functions returns the total number of elements in a vector.
► length();
► size(); (Page 318)
► ele();
► veclen();

35
Question No: 19 ( Marks: 1 ) - Please choose one
Suppose you create an uninitialized vector as follows:

vector<int> evec;
After adding the statment,
evec.push_back(21);
what will happen?
► The following statement will add an element to the start (the back) of evec and will initialize it with the
value 21.
► The following statement will add an element to the center of evec and will reinitialize it with the value
21.
► The following statement will delete an element to the end (the back) of evec and will reinitialize it with
the value 21.
► The following statement will add an element to the end (the back) of evec and initialize it with the
value 21. Click here for detail

Question No: 20 ( Marks: 1 ) - Please choose one


An STL container can not be used to,
► hold objects of class employee.
► store elements in a way that makes them quickly accessible.
► compile c++ programs. (Object-Oriented Programming in C++) rep
► organize the way objects are stored in memory

Question No: 21 ( Marks: 1 ) - Please choose one


Algorithms can only be implemented using STL containers.
► True
► False (Object-Oriented Programming in C++) rep

Question No: 22 ( Marks: 1 ) - Please choose one


The main function of scope resolution operator (::) is,
► To define an object
► To define a data member
► To link the definition of an identifier to its declaration Click here for detail
► To make a class private

Question No: 23 ( Marks: 1 ) - Please choose one


When is a constructor called?
► Each time the constructor identifier is used in a program statement
► During the instantiation of a new object (Object-Oriented Programming in C++)
► During the construction of a new class
► At the beginning of any program execution

36
Question No: 24 ( Marks: 1 ) - Please choose one
Consider the code below,
class Fred {
public:
Fred();
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];
...
}
Select the best option,
► Fred a[10]; calls the default constructor 09 times
Fred* p = new Fred[10];
► Produce an error
► Fred a[10]; calls the default constructor 11 times
Fred* p = new Fred[10]; calls the default constructor 11 times
► Fred a[10]; calls the default constructor 10 times
Fred* p = new Fred[10]; calls the default constructor 10 times Click here for detail

Question No: 25 ( Marks: 1 ) - Please choose one


Associativity can be changed in operator overloading.

► True
► False (Page 141)

Question No: 26 ( Marks: 1 ) - Please choose one


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

► glorified.
► encapsulated.
► classified.
► overloaded. (Object-Oriented Programming in C++)

Question No: 27 ( Marks: 1 ) - Please choose one


Which operator can not be overloaded?

► The relation operator ( >= )


► Assignment operator ( = )
► Script operator ( [] )
► Conditional operator (? : ) (Page 141)

37
Question No: 28 ( Marks: 1 ) - Please choose one
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 operator + ( A &obj);
► int + operator(); (Page 143)
► int operator (plus) ();
► A operator(A &obj3);

Question No: 29 ( Marks: 1 ) - Please choose one


Default constructor is such constructor which either has no ---------or if it has some parameters these have -----
--- values
► Parameter, temporary
► Null, Parameter
► Parameter, default (Page 75) rep
► non of the given

Question No: 30 ( Marks: 1 ) - Please choose one


Public methods of base class can --------- be accessed in its derived class
► directly (Page 179) rep
► inderectly
► simultaniously
► non of the given

38
Cs304 Important Mcq’s For Final Term
Solve By Vu_Toper RM
What’s app 03224021365
Paid Tasks = LMS Handling + Online Classes + Project
A template provides a convenient way to make a family of.
variables and data members
functions and classes
classes and exceptions
programs and algorithms
A class template may inherit from another class template.
True
False
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
A class hierarchy .
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.
Sender of the message does not need to know the exact class of receiver
in______.
Abstraction
Polymorphism
Inheritance
none of the given
A function call is resolved at run-time in_________ .
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given
Adding a derived class to a base class requires fundamental changes to the
base class.
True
False
User can make virtual table explicitly.
True
False
Binding means that target function for a call is selected at compile time.
Static
Dynamic
Automatic
None of given
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
Which line will produce error. Class phone: private Transmit, private Receiver { }
1. int main() 2. { 3. phone obj; 4. Tranmit* obj1 = &obj; 5. Received obj2 = &obj; 6.
}.
3rd line will produce error
4th line will produce error
3rd and 4th line will produce error.
5th line will produce error
Function overriding is done in context of,
Single class
Single derived class
Single base class
Derived and base classes
Consider the code below, class class1{ public: void func1(); }; class class2 :
protected class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
The following statements: 1) int iArray[5]; 2) int *pArr = iArray;
These statements will compile successfully
Error in first statement
Error in second statement
None of given options
Methodologies to the development of reusable software relate to________.
Structure programming
procedural programming
generic programming
None of the given
Function template must have a parameter.
True
False
The default inheritance mode is,
Public inheritance
Protected inheritance
Private inheritance
None of these options
Two functions with same names, parameters and return type can exist in,
Function overloading
Function overriding
Operator overloading
None of these options
Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2
{ }; Then c2 is,
Direct base class of c3
Direct child class of c3
Direct base class of c1
None of these
Virtual functions allow you to
create an array of type pointer-to-base class that can hold pointers to derived classes.
create functions that can never be accessed.
group objects of different classes so they can all be accessed by the same
function code.
use the same function call to execute member functions of objects from different
classes.
User can make virtual table explicitly.
True
False
In order to define a class template the first line of definition must be:
template <typename T>
typename <template T>
Template Class <ClassName>
Class <Template T>
Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;
These statements will compile successfully
Error in first statement
Error in second statement
None of given options
In c++ dynamic binding and polymorphism will be achieved when member
function will be __.
private
public
virtual
inline
In type in depended function template should be use where code and behavior
must be identical.
True
False
Consider the code below, class class1{ protected: int i; }; class class2 : private
class1 { }; Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
In specialization we can,
Replace child class with its base class
Replace base class with its child class (Not Sure)
Replace both child and base classes interchangeably
None of the given options
Consider the code below, class class1{ public: void func1(); }; class class2 :
public class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
It is illegal to make objects of one class members of another class.
True
False
An abstract class is useful when
no classes should be derived from it.
there are multiple paths from one derived class to another.
no objects should be instantiated from its.
you want to defer the declaration of the class.
In resolution order compiler search firstly _______.
Generic Template
Partial Specialization
Complete Specialization
Ordinary function
template<> class Vector{ void** p; //.... void*& operator[] ((int i); };
This specialization can then be used as the common implementation for all Vectors of
pointers.
This specialization can then be used as the all type implementation for one type
classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.
In private inheritance derived class pointer can be assigned to base class
pointer in.
Main function
In derived class member and friend functions
In base class member and friend functions
None of the given options
Which statement will be true for concrete class?
it implements an virtual concept.
it can be instantiated
it cannot be instantiated
none of given
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
The Specialization pattern after the name says that this specialization is to be
used for every___.
data types
meta types
virtual types
pointers type
c++ dynamic binding and polymorphism will be achieved when member function
will be __.
private
public
virtual
inline
Consider the code below, class class1{ protected: void func1(); }; class class2 :
public class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class class1{ protected: int i; }; class class2 :
protected class1 { }; Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class class1{ private: void func1(); }; class class2 :
private class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;
These statements will compile successfully
Error in first statement
Error in second statement
None of given options
Consider the code below, class class1{ private: int i; }; class class2 : private
class1 { }; Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
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.
base
derived
virtual
implemented
A class template may inherit from another class template.
True
False
Derived class can inherit from public base class as well as private and protected
base classes
True
False
Two functions with same names, parameters and return type can exist in,
Function overloading
Function overriding
Operator overloading
None of these options
Consider the code below, class class1{ private: int i; }; class class2 : public
class1 { }; Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
A class template may inherit from another class template.
True
False
A function call is resolved at run-time in_________
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given
A class hierarchy
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.
Consider the code below, class class1{ public: int i; }; class class2 : public
class1 { }; Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2
{ }; Then c1 is,
Direct base class of c3
Direct child class of c3
Direct base class of c2
Direct child class of c2
A class can inherit from more then one class is called.
Simple inheritance
Multiple inheritances
Single inheritance
Double inheritance
template<> class Vector{ void** p; //.... void*& operator[] ((int i); };
This specialization can then be used as the common implimentation for all Vectors of
pointers.
This spcialization can then be used as the all type implimentation for one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.
Consider the code below, class class1{ public: int i; }; class class2 : protected
class1 { }; Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class class1{ private: void func1(); }; class class2 :
public class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
Templates automatically create different versions of a function, depending on
user input.
True
False
________ Binding means that target function for a call is selected at run time
Automatic
Dynamic
Static
Dramatic
When we create objects, then space is allocated to:
Member function
Access specifier
Data member
None of given
There is only one form of copy constructor.
True
False
Which of the following features of OOP is used to deal with only relevant
details?
Abstraction
Information hiding
Object
___________ Binding means that targets function for a call is selected at compile
time.
Static
Dynamic
Automatic
None of given
A Class hierarchy
Shows the same relationships as an organization chart
Describes “has a” relationships.
Describes “is a kind of” relationships.
Shows the same relationships as a family tree
In C++, we declare a function virtual by preceding the function header with
keyword “Inline”.
True
False
It is illegal to make objects of one class members of another class.
True
False
In Resolution order compiler search firstly____________.
Generic Template
Partial Specification
Complete Specification
Ordinary function

Derived class can inherit from public base class as well as private and protected
base classes
True
False
Which line will produce error. Class phone: Private Transmit, private Receiver { }
1.int main () 2. { 3.phone obj; 4.Tranmit*obj1 = &obj; 5.Received obj2 = &obj; 6.}
3rd line will produce error
4th line will produce error
3rd and 4th line will produce error.
5th line will produce error.
Methodologies to the development of reusable software relate to ____________.
Structure programming
Procedural programming
Generic programming
None of the given
A template argument is preceded by the keyword__________.
Vector
Class
Template
Type*
Friends are used exactly the same for template and non-template classes.
True
False
A function template must have a parameter
True
False

Child class can call constructor of its,


Direct base class
Indirect base class
Both direct and indirect base classes
None of these.

Which statement will be true for concrete class?


It implements an virtual concept.
It can be instantiated
It cannot be instantiated
None of given

A class D can be derived from a class C, which is derived froma class B, which
is derived from a class A
True
False
Adding a derived class to a base class requires fundamental changes to the
base class.
True
False

A Class or class template can have member ___________ that are themselves
templates.
Variable
Function
Objects
None of given

Which will be the Primary task or tasks of generic programming?


Categorize the abstractions in a domain into concepts
Implement generic algorithms based on the concepts
Build concrete models of the concepts
All of given

The default inheritance mode is,


Public inheritance
Protected Inheritance
Private Inheritance
None of these options

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.
Base
Derived
Virtual
Implemented

Sender of the message does not need to know the exact class of receiver
in________.
Abstraction
Polymorphism
Inheritance
none of the given
Child class can call constructor of its,
Direct base class
Indirect base class
Both direct and indirect base classes
None of these

A pure virtual function is a virtual function that


causes its class to be abstract.
returns nothing.
is used in a derived class.
takes no arguments.
1: Consider the code below, class class1{ protected: int i; }; class class2 :
protected class1 { }; Then int member i of class1 is ______ in class2,
▪ public
▪ protected (true)

2: By default, assignment operator (=) performs,


▪ Shallow copy (true)
▪ Deep copy

3: The default inheritance mode is,


▪ Public inheritance( true)

4: In case of dynamic memory allocation in our class we should use


▪ Default assignment operator
▪ copy constructor(true)

5: Static casting is,?


▪ Implicit way of calling base class functions from derived class (true)
▪ Explicit way of calling base class functions from derived class
▪ None of these
▪ both 1 and 2

6: In case of dynamic memory allocation in a class we should use,


▪ User defined default constructor
▪ user difined copy constructor (true)

7: Which of the following types of Inheritance is used to model


“Implemented in terms of” relationship?
▪ Public
▪ private (true)
▪ Protected

8: Virtual functions allow you to


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

9: A class D can be derived from a class C, which is derived from a class B,


which is derived from a class A.
▪ T (true ans)
▪ F

10: Function overriding is done in context of,


▪ Single class
▪ Single derived class
▪ base and drived class (true)
1: Consider the code below, class class1{ protected: int i; }; class class2 :
protected class1 { }; Then int member i of class1 is ______ in class2,
▪ public
▪ protected (true)

2: By default, assignment operator (=) performs,


▪ Shallow copy (true)
▪ Deep copy

3: The default inheritance mode is,


▪ Public inheritance( true)

4: In case of dynamic memory allocation in our class we should use


▪ Default assignment operator
▪ copy constructor(true)

5: Static casting is,?


▪ Implicit way of calling base class functions from derived class (true)
▪ Explicit way of calling base class functions from derived class
▪ None of these
▪ both 1 and 2

6: In case of dynamic memory allocation in a class we should use,


▪ User defined default constructor
▪ user difined copy constructor (true)

7: Which of the following types of Inheritance is used to model


“Implemented in terms of” relationship?
▪ Public
▪ private (true)
▪ Protected

8: Virtual functions allow you to


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

9: A class D can be derived from a class C, which is derived from a class B,


which is derived from a class A.
▪ T (true ans)
▪ F

10: Function overriding is done in context of,


▪ Single class
▪ Single derived class
▪ base and drived class (true)
Friend Functions of a class are
_________ members of that class .
Select correct option :
Public
Private
Protected
None of the given options .
Question # 2 of 10 ( Start time:
02 :17 :30 PM ) Total Marks: 1
Consider the code below , class
class1 { protected : int i ; }; class
class2 : protected class1 { }; Then int
member i of class1 is ______ in class 2 ,
Select correct option :
public
protected
private
none of the given options
Question # 3 of 10 ( Start time:
02 :17 :56 PM ) Total Marks: 1
A Child class can call constructor of its
parent class through ,
Select correct option :
Its constructor initialization list
Its constructor body
Both from its constructor initialization
list or body -
Can not call the constructor of its
parent class
Question # 4 of 10 ( Start time:
02 :19 :01 PM ) Total Marks: 1 We can
access private members of the class
from outside the class using ______
operator with its object pointer .
Select correct option :
->
.
&
None of the given options
Question # 5 of 10 ( Start time:
02 :20 :13 PM ) Total Marks: 1
A function call is resolved at run - time
in ___________
Select correct option :
non - virtual member function
virtual member function
Both non - virtual member and virtual
member function .
None of given
Question # 6 of 10 ( Start time:
02 :20 :35 PM ) Total Marks: 1
It is sometimes useful to specify a
class from which no objects will ever be
created .
Select correct option :
True
Flase
Question # 7 of 10 ( Start time:
02 :21 :01 PM ) Total Marks: 1
Consider the code below , class
class1 { public: void func 1 (); }; class
class2 : private class 1 { }; Function
func1 of class1 is ______ in class 2 ,
Select correct option :
public
protected
private
none of the given options
Question # 8 of 10 ( Start time:
02 :21 :26 PM ) Total Marks: 1
Consider the code below , class
class1 { public: int i ; }; class class 2 :
protected class 1 { }; Then int member i
of class 1 is ______ in class2 ,
Select correct option :
public
protected
private
none of the given options
Question # 9 of 10 ( Start time:
02 :22 :00 PM ) Total Marks: 1
Static casting is,
Select correct option :
Implicit way of calling base class
functions from derived class
Explicit way of calling base class
functions from derived class
None of these
Both of these

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


variables and data members
functions and classes
classes and exceptions
programs and algorithms
A class template may inherit from another class template.
True
False
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
A class hierarchy .
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.
Sender of the message does not need to know the exact class of receiver in______.
Abstraction
Polymorphism
Inheritance
none of the given
A function call is resolved at run-time in_________ .
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given
Adding a derived class to a base class requires fundamental changes to the base class.
True
False
User can make virtual table explicitly.
True
False
Binding means that target function for a call is selected at compile time.
Static
Dynamic
Automatic
None of given
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
Which line will produce error. Class phone: private Transmit, private Receiver { } 1. int
main() 2. { 3. phone obj; 4. Tranmit* obj1 = &obj; 5. Received obj2 = &obj; 6. }.
3rd line will produce error
4th line will produce error
3rd and 4th line will produce error.
5th line will produce error
Function overriding is done in context of,
Single class
Single derived class
Single base class
Derived and base classes
Consider the code below, class class1{ public: void func1(); }; class class2 : protected
class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
The following statements: 1) int iArray[5]; 2) int *pArr = iArray;
These statements will compile successfully
Error in first statement
Error in second statement
None of given options
Methodologies to the development of reusable software relate to________.
Structure programming
procedural programming
generic programming
None of the given
Function template must have a parameter.
True
False
The default inheritance mode is,
Public inheritance
Protected inheritance
Private inheritance
None of these options
Two functions with same names, parameters and return type can exist in,
Function overloading
Function overriding
Operator overloading
None of these options
Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then
c2 is,
Direct base class of c3
Direct child class of c3
Direct base class of c1
None of these
Virtual functions allow you to
create an array of type pointer-to-base class that can hold pointers to derived classes.
create functions that can never be accessed.
group objects of different classes so they can all be accessed by the same function code.
use the same function call to execute member functions of objects from different classes.
User can make virtual table explicitly.
True
False
In order to define a class template the first line of definition must be:
template <typename T>
typename <template T>
Template Class <ClassName>
Class <Template T>
Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;
These statements will compile successfully
Error in first statement
Error in second statement
None of given options
In c++ dynamic binding and polymorphism will be achieved when member function will
be __.
private
public
virtual
inline
In type in depended function template should be use where code and behavior must be
identical.
True
False
Consider the code below, class class1{ protected: int i; }; class class2 : private class1 { };
Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
In specialization we can,
Replace child class with its base class
Replace base class with its child class (Not Sure)
Replace both child and base classes interchangeably
None of the given options
Consider the code below, class class1{ public: void func1(); }; class class2 : public class1
{ }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
It is illegal to make objects of one class members of another class.
True
False
An abstract class is useful when
no classes should be derived from it.
there are multiple paths from one derived class to another.
no objects should be instantiated from its.
you want to defer the declaration of the class.
In resolution order compiler search firstly _______.
Generic Template
Partial Specialization
Complete Specialization
Ordinary function
template<> class Vector{ void** p; //…. void*& operator[] ((int i); };
This specialization can then be used as the common implementation for all Vectors of
pointers.
This specialization can then be used as the all type implementation for one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.
In private inheritance derived class pointer can be assigned to base class pointer in.
Main function
In derived class member and friend functions
In base class member and friend functions
None of the given options
Which statement will be true for concrete class?
it implements an virtual concept.
it can be instantiated
it cannot be instantiated
none of given
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
The Specialization pattern after the name says that this specialization is to be used for
every___.
data types
meta types
virtual types
pointers type
c++ dynamic binding and polymorphism will be achieved when member function will
be __.
private
public
virtual
inline
Consider the code below, class class1{ protected: void func1(); }; class class2 : public
class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class class1{ protected: int i; }; class class2 : protected class1 {
}; Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class class1{ private: void func1(); }; class class2 : private
class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;
These statements will compile successfully
Error in first statement
Error in second statement
None of given options
Consider the code below, class class1{ private: int i; }; class class2 : private class1 { };
Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
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.
base
derived
virtual
implemented
A class template may inherit from another class template.
True
False
Derived class can inherit from public base class as well as private and protected base
classes
True
False
Two functions with same names, parameters and return type can exist in,
Function overloading
Function overriding
Operator overloading
None of these options
Consider the code below, class class1{ private: int i; }; class class2 : public class1 { };
Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given
A class template may inherit from another class template.
True
False
A function call is resolved at run-time in_________
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given
A class hierarchy
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.
Consider the code below, class class1{ public: int i; }; class class2 : public class1 { }; Then
int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then
c1 is,
Direct base class of c3
Direct child class of c3
Direct base class of c2
Direct child class of c2
A class can inherit from more then one class is called.
Simple inheritance
Multiple inheritances
Single inheritance
Double inheritance
template<> class Vector{ void** p; //…. void*& operator[] ((int i); };
This specialization can then be used as the common implimentation for all Vectors of
pointers.
This spcialization can then be used as the all type implimentation for one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.
Consider the code below, class class1{ public: int i; }; class class2 : protected class1 { };
Then int member i of class1 is ____ in class2,
public
protected
private
none of the given options
Consider the code below, class class1{ private: void func1(); }; class class2 : public
class1 { }; Function func1 of class1 is ____ in class2,
public
protected
private
none of the given options
Templates automatically create different versions of a function, depending on user
input.
True
False
________ Binding means that target function for a call is selected at run time
Automatic
Dynamic
Static
Dramatic
When we create objects, then space is allocated to:
Member function
Access specifier
Data member
None of given
There is only one form of copy constructor.
True
False
Which of the following features of OOP is used to deal with only relevant details?
Abstraction
Information hiding
Object
___________ Binding means that targets function for a call is selected at compile time.
Static
Dynamic
Automatic
None of given
A Class hierarchy
Shows the same relationships as an organization chart
Describes “has a” relationships.
Describes “is a kind of” relationships.
Shows the same relationships as a family tree
In C++, we declare a function virtual by preceding the function header with keyword
“Inline”.
True
False
It is illegal to make objects of one class members of another class.
True
False
In Resolution order compiler search firstly____________.
Generic Template
Partial Specification
Complete Specification
Ordinary function
Derived class can inherit from public base class as well as private and protected base
classes
True
False
Which line will produce error. Class phone: Private Transmit, private Receiver { } 1.int
main () 2. { 3.phone obj; 4.Tranmit*obj1 = &obj; 5.Received obj2 = &obj; 6.}
3rd line will produce error
4th line will produce error
3rd and 4th line will produce error.
5th line will produce error.
Methodologies to the development of reusable software relate to ____________.
Structure programming
Procedural programming
Generic programming
None of the given
A template argument is preceded by the keyword__________.
Vector
Class
Template
Type*
Friends are used exactly the same for template and non-template classes.
True
False
A function template must have a parameter
True
False

Child class can call constructor of its,


Direct base class
Indirect base class
Both direct and indirect base classes
None of these.
Which statement will be true for concrete class?
It implements an virtual concept.
It can be instantiated
It cannot be instantiated
None of given
A class D can be derived from a class C, which is derived froma class B, which is derived
from a class A
True
False

Adding a derived class to a base class requires fundamental changes to the base class.
True
False

A Class or class template can have member ___________ that are themselves templates.
Variable
Function
Objects
None of given

Which will be the Primary task or tasks of generic programming?


Categorize the abstractions in a domain into concepts
Implement generic algorithms based on the concepts
Build concrete models of the concepts
All of given

The default inheritance mode is,


Public inheritance
Protected Inheritance
Private Inheritance
None of these options

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.
Base
Derived
Virtual
Implemented

Sender of the message does not need to know the exact class of receiver in________.
Abstraction
Polymorphism
Inheritance
none of the given
Question # 1 of 20 ( Start time: 08:20:11 PM ) Total Marks: 1
A Child class can call constructor of its parent class through,
Select correct option:
Its constructor initialization list (Correct)
Its constructor body
Both from its constructor initialization list or body
Can not call the constructor of its parent classQuestion # 2 of 20 ( Start time: 08:21:46 PM
) Total Marks: 1
A class template may inherit from another class template.
Select correct option:True
False (False)
Question # 3 of 20 ( Start time: 08:22:17 PM ) Total Marks: 1
Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then
c2 is,
Select correct option:

Direct base class of c3


Direct child class of c3 (Correct)
Direct base class of c1
None of these

Question # 4 of 20 ( Start time: 08:22:57 PM ) Total Marks: 1


Child class can call constructor of its,
Select correct option:

Direct base class (Correct)


Indirect base class
Both direct and indirect base classes
None of these

Question # 5 of 20 ( Start time: 08:23:26 PM ) Total Marks: 1


Consider the code below, class class1{ public: void func1(); }; class class2 : protected
class1 { }; Function func1 of class1 is ______ in class2,
Select correct option:

public
protected
private (Correct)
none of the given options

Question # 6 of 20 ( Start time: 08:24:08 PM ) Total Marks: 1


A class hierarchy
Select correct option:

shows the same relationships as an organization chart.


describes “has a” relationships.
describes “is a kind of” relationships. (Correct)
shows the same relationships as a family tree.

Question # 7 of 20 ( Start time: 08:24:47 PM ) Total Marks: 1


Consider the code below, class class1{ public: void func1(); }; class class2 : public class1
{ }; Function func1 of class1 is ______ in class2,
Select correct option:
public (Correct)
protected
private
none of the given options

Question # 8 of 20 ( Start time: 08:26:03 PM ) Total Marks: 1


In C++, we declare a function virtual by preceding the function header with keyword
“Inline”
Select correct option:

True (Correct)
False

Question # 9 of 20 ( Start time: 08:26:37 PM ) Total Marks: 1


Consider the code below, class class1{ private: int i; }; class class2 : protected class1 { };
Then int member i of class1 is ______ in class2,
Select correct option:

public
protected (Correct)
private
none of the given options

Question # 10 of 20 ( Start time: 08:27:39 PM ) Total Marks: 1


Which will be the Primary task or tasks of generic programming?
Select correct option:

Categorize the abstractions in a domain into concepts


Implement generic algorithms based on the concepts
Build concrete models of the concepts
All of given (Correct)

Question # 11 of 20 ( Start time: 08:28:04 PM ) Total Marks: 1


When we want to implement one class in terms of another class then we use,
Select correct option:

Public inheritance (Correct)


Protected inheritance
Private inheritance
None of these options

Question # 12 of 20 ( Start time: 08:29:20 PM ) Total Marks: 1


Virtual functions allow you to
Select correct option:

create an array of type pointer-to-base class that can hold pointers to derived classes.
create functions that can never be accessed.
group objects of different classes so they can all be accessed by the same function
code. (Correct)
use the same function call to execute member functions of objects from different classes.
Question # 13 of 20 ( Start time: 08:30:05 PM ) Total Marks: 1
A class or class template can have member _________ that are themselves templates.
Select correct option:

Variable
Function
Objects
None of given (Correct)

Question # 14 of 20 ( Start time: 08:31:34 PM ) Total Marks: 1


A class template ____________
Select correct option:

Facilitates reuse of class (Correct)


Does not facilitate reuse of class
Does not support generic methods
Does not support static members

Question # 15 of 20 ( Start time: 08:32:48 PM ) Total Marks: 1


Target of a _______ function call is determined at run time.
Select correct option:

instance
virtual (Correct)
operator
none of given

Question # 16 of 20 ( Start time: 08:34:18 PM ) Total Marks: 1


The default inheritance mode is,
Select correct option:

Public inheritance (Correct)


Protected inheritance
Private inheritance
None of these options

Question # 17 of 20 ( Start time: 08:34:54 PM ) Total Marks: 1


A class D can be derived from a class C, which is derived from a class B, which is derived
from a class A.
Select correct option:

True (Correct)
False

Question # 18 of 20 ( Start time: 08:36:11 PM ) Total Marks: 1


A pure virtual function is a virtual function that
Select correct option:

causes its class to be abstract. (Correct)


returns nothing.
is used in a derived class.
takes no arguments.

Question # 19 of 20 ( Start time: 08:36:47 PM ) Total Marks: 1


A template provides a convenient way to make a family of
Select correct option:

variables and data members (Correct)


functions and classes
classes and exceptions
programs and algorithms

Question # 20 of 20 ( Start time: 08:37:17 PM ) Total Marks: 1


Consider the code below, class class1{ protected: int i; }; class class2 : protected class1 {
}; Then int member i of class1 is ______ in class2,
Select correct option:

public
protected
private (Correct)
none of the given options

Quiz No. 02 of the subject Object Oriented Programming (CS304) is going to upload in a
couple of days, before submitting the Quiz, please read all instructions thoroughly.

Quiz No. 02 of the subject Object Oriented Programming (CS304) is going to upload in a
couple of days, before submitting the Quiz, please read all instructions thoroughly.
Solved Today Quiz

Question # 1 of 10 ( Start time: 01:59:09 PM )


What will be most appropriate C++ data type for variable “InterestRate”?
Select correct option:
int
long int
double
=>float
Question # 2 of 10 ( Start time: 01:59:59 PM )
Select correct line of code for aggregation relationship between “Person” class and “Address”
class.
Select correct option:

=>class Person { Address * a; };


class Address { Person * a; };
class Person { Address a; };
class Address { Person a; };
Question # 3 of 10 ( Start time: 02:01:24 PM )
__________is creating objects of one class inside another class.
Select correct option:
Aggregation
=>Composition
Inheritance
Association
Question # 4 of 10 ( Start time: 02:02:03 PM )
What type of relationship exists between “SavingAccount” class and “CurrentAccount” class?
Select correct option:
Both are child classes
Both contains each other
=?Both are composed of each other
None of the given option
Question # 5 of 10 ( Start time: 02:03:28 PM )
In ______________destructor of sub-object is called after destructor of master class.
Select correct option:
Aggregation
=>Composition
Inheritance
Association
Question # 6 of 10 ( Start time: 02:04:53 PM )
Select correct line of code for inheritance relationship between “Keys” class and
“StandardKeys” class. “Keys” is parent class while “StandardKeys” is child class.
Select correct option:
=>class StandardKeys: public Keys
class Keys: public StandardKeys
class StandardKeys:: public Keys
class Keys:: public StandardKeys
Question # 7 of 10 ( Start time: 02:06:07 PM )
Select correct line of code for aggregation relationship between “Person” class and “Phone”
class.
Select correct option:
=>class Person { Phone * p; };
class Phone { Person * p; };
class Person { Phone p; };
class Phone { Person p; };
Question # 8 of 10 ( Start time: 02:07:09 PM )
“Keyboard” class is composed off “keys” class. What will be the order of execution of
destructor of “Keyboard” class and “Keys” class?
Select correct option:
First Detructor::Keys.. Second Destructor::Keyboard..
=>First Destructor:: Keyboard.. Second Destructor:: Keys..
Question # 9 of 10 ( Start time: 02:08:38 PM )
There is an object of type Person, which of the following can be considered as one of its
attributes:
Select correct option:
Name
Workat()
Age
=>Both age and name
Question # 10 of 10 ( Start time: 02:09:27 PM )
Select correct line of code for composition relationship between “Keyboard” class and “Keys”
class.
Select correct option:
=>class keyboard { Keys type;};
class keys{ KeyBoard type; };
class keyboard : private keys
class keys: private KeyBoard
In _______________ a pointer or reference to an object is created inside a class
Select correct option:
Aggregation
Composition
Seperation
None of the given
Sub-Object can not be initialized using the constructor
Select correct option:
True
False

To initialize an array of objects, only _____________ will be called


Select correct option:

Defualt Constructor
Overloaded Constructor
Default Object
None of the above
Let Suppose a class Student with objects std1, std2, and std3. For the statement std3 = std1 –
std2 to work correctly, if the overloaded – operator must
Select correct option:

take two arguments.


None of the given choices
take single argument
take three arguments

Copy constructor is called when:


Select correct option:

An object is created in term of pre existence object


An object is created
An object is initialized
None of the given
Which of the following operator doesn’t take any argument if overloaded?
Select correct option:

/

+
None of the given choices

Object can be declared constant with the use of Constant keyword.


Select correct option:

True
False
Always make pointer to null, whenever dynamic memory is deleted.
Select correct option:

True
False
__________ provide the facility to access the data member.
Select correct option:
accesser function
private function
inline function
None of the given
Question # 1 of 10 ( Start time: 02:16:16 PM ) Total Marks: 1
Friend Functions of a class are _________ members of that class.
Select correct option:
Public
Private
Protected
None of the given options.
Question # 2 of 10 ( Start time: 02:17:30 PM ) Total Marks: 1
Consider the code below, class class1{ protected: int i; }; class class2 : protected class1 { };
Then int member i of class1 is ______ in class2,
Select correct option:

public
protected
private
none of the given options
Question # 3 of 10 ( Start time: 02:17:56 PM ) Total Marks: 1
A Child class can call constructor of its parent class through,
Select correct option:

Its constructor initialization list


Its constructor body
Both from its constructor initialization list or body –
Can not call the constructor of its parent class
Question # 4 of 10 ( Start time: 02:19:01 PM ) Total Marks: 1 We can access private members
of the class from outside the class using ______ operator with its object pointer.
Select correct option:
->
.
&
None of the given options
Question # 5 of 10 ( Start time: 02:20:13 PM ) Total Marks: 1
A function call is resolved at run-time in___________
Select correct option:

non-virtual member function


virtual member function
Both non-virtual member and virtual member function.
None of given
Question # 6 of 10 ( Start time: 02:20:35 PM ) Total Marks: 1
It is sometimes useful to specify a class from which no objects will ever be created.
Select correct option:
True
Flase
Question # 7 of 10 ( Start time: 02:21:01 PM ) Total Marks: 1
Consider the code below, class class1{ public: void func1(); }; class class2 : private class1 { };
Function func1 of class1 is ______ in class2,
Select correct option:
public
protected
private
none of the given options
Question # 8 of 10 ( Start time: 02:21:26 PM ) Total Marks: 1
Consider the code below, class class1{ public: int i; }; class class2 : protected class1 { }; Then
int member i of class1 is ______ in class2,
Select correct option:

public
protected
private
none of the given options
Question # 9 of 10 ( Start time: 02:22:00 PM ) Total Marks: 1
Static casting is,
Select correct option:

Implicit way of calling base class functions from derived class

Explicit way of calling base class functions from derived class

None of these

Both of these
Question # 10 of 10 ( Start time: 02:23:15 PM ) Total Marks: 1
Consider the code below, class class1{ protected: void func1(); }; class class2 : public class1 { };
Function func1 of class1 is ______ in class2,
Select correct option:

public
protected

private

none of the given option

BS(CS)Permalink Reply by ║ ͫ ䷸䷸║㏘ on June 14, 2013 at 9:50pm


My Quizzzzzz
__________ Operator will take only one operant.

New

int

object

Unary operators and assignment operator are right associative.

True
False

We can create array of objects if we have a user defined constructor.

True

False

Object can be declared constant with the use of Constant keyword.

True

False

To initialize an array of objects, only _____________ will be called

Defualt Constructor

Overloaded Constructor

Default Object

None of the above

Let Suppose a class Student with objects std1, std2, and std3. For the statement std3 = std1 –
std2 to work correctly, if the overloaded – operator must

take two arguments.

None of the given choices

take single argument

take three arguments

__________ provide the facility to access the data member.

accesser function

private function

inline function

None of the given

Static variable can be initialized more than once.


True

False

_____ is creating objects of one class inside another class.

Association

Composition

Aggregation

Inheritance

Which of the following operator(s) take(s) one or no argument if overloaded?

++

All of the given choices

Question No.1 Time :90 second Marks-1


Sender of the message does not need to know the exact class of receiver in______.
Please chose one
1) Abstraction
2) Polymorphism
3) Inheritance
4) none of the given
Answer: 2
Question No.2 Time :90 second Marks-1
Target of a _____ function call is determined at run time.
Please chose one
1) instance
2) virtual
3) operator
4) none of given
Answer: 2
Question No.3 Time :90 second Marks-1
A function call is resolved at run-time in_________ .
Please chose one
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given
Answer: 3
Question No.4 Time :90 second Marks-1
Consider the code below, class class1{ public: void func1(); }; class class2 : protected class1 { };
Function func1 of class1 is ____ in class2,
Please chose one
public
protected
private
none of the given options
Answer: 2
Question No.5 Time :90 second Marks-1
Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then c2 is,
Please chose one
Direct base class of c3
Direct child class of c3
Direct base class of c1
None of these
Answer: 1
Question No.6 Time :90 second Marks-1
A template provides a convenient way to make a family of.
Please chose one
1) variables and data members
2) functions and classes
3) classes and exceptions
4) programs and algorithms
Answer: 2
Question No.7 Time :90 second Marks-1
Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then c1 is,
Please chose one
Direct base class of c3
Direct child class of c3
Direct base class of c2
Direct child class of c2
Answer: 2
Question No.8 Time :90 second Marks-1
User can make virtual table explicitly.
Please chose one
True
False
Answer: 1
Question No.9 Time :90 second Marks-1
In type in depended function template should be use where code and behavior must be
identical.
Please chose one
True
False
Answer: 1

Child class can call constructor of its,


Direct base class
Indirect base class
Both direct and indirect base classes
None of these
A pure virtual function is a virtual function that
causes its class to be abstract.
returns nothing.
is used in a derived class.
takes no arguments.
https://www.vuvickypro.com/2018/08/cs304-solved-quizzes-file-1.html
check this link for important mcqs for final term
www.vuplanet.com

CS304 - Object Oriented Programming


Quiz No. 3, Feb 07, 2013
A template provides a convenient way to make a family of
Select correct option:
variables and data members
functions and classes
classes and exceptions
programs and algorithms

A class template may inherit from another class template.


Select correct option:
True
False

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given

A class hierarchy
Select correct option:
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.

Sender of the message does not need to know the exact class of receiver in______.
Select correct option:
Abstraction
Polymorphism
Inheritance
none of the given

A function call is resolved at run-time in_________


Select correct option:
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given
www.vuplanet.com

Adding a derived class to a base class requires fundamental changes to the base class.
Select correct option:
True
False

User can make virtual table explicitly.


Select correct option:
True
False

Binding means that target function for a call is selected at compile time.
Select correct option:
Static
Dynamic
Automatic
None of given

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given

Which line will produce error. Class phone: private Transmit, private Receiver { } 1. int
main() 2. { 3. phone obj; 4. Tranmit* obj1 = &obj; 5. Received obj2 = &obj; 6. }
Select correct option:
3rd line will produce error
4th line will produce error
3rd and 4th line will produce error.
5th line will produce error

Function overriding is done in context of,


Select correct option:
Single class
Single derived class
Single base class
Derived and base classes

Consider the code below, class class1{ public: void func1(); }; class class2 : protected
class1 { }; Function func1 of class1 is ____ in class2,
www.vuplanet.com

Select correct option:


public
protected
private
none of the given options

the following statements: 1) int iArray[5]; 2) int *pArr = iArray;


Select correct option:
These statements will compile successfully
Error in first statement
Error in second statement
None of given options

Methodologies to the development of reusable software relate to________.


Select correct option:
Structure programming
procedural programming
generic programming
None of the given

function template must have a parameter.


Select correct option:
True
False

The default inheritance mode is,


Select correct option:
Public inheritance
Protected inheritance
Private inheritance
None of these options

Two functions with same names, parameters and return type can exist in,
Select correct option:
Function overloading
Function overriding
Operator overloading
None of these options

Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then
c2 is,
Select correct option:

Direct base class of c3


www.vuplanet.com

Direct child class of c3


Direct base class of c1
None of these

Virtual functions allow you to


Select correct option:
create an array of type pointer-to-base class that can hold pointers to derived classes.
create functions that can never be accessed.
group objects of different classes so they can all be accessed by the same function
code.
use the same function call to execute member functions of objects from different
classes.
User can make virtual table explicitly.
Select correct option:
True
False

In order to define a class template the first line of definition must be:
Select correct option:
template <typename T>
typename <template T>
Template Class <ClassName>
Class <Template T>

Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;


Select correct option:
These statements will compile successfully
Error in first statement
Error in second statement
None of given options

In c++ dynamic binding and polymorphism will be achieved when member function will
be __.
Select correct option:
private
public
virtual
inline

In type in depended function template should be use where code and behavior must be
identical.
Select correct option:
www.vuplanet.com

True
False

Consider the code below, class class1{ protected: int i; }; class class2 : private class1 { };
Then int member i of class1 is ____ in class2,
Select correct option:

public
protected
private
none of the given options

In specialization we can,
Select correct option:
Replace child class with its base class
Replace base class with its child class (Not Sure)
Replace both child and base classes interchangeably
None of the given options

Consider the code below, class class1{ public: void func1(); }; class class2 : public class1 {
}; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

It is illegal to make objects of one class members of another class.


Select correct option:
True
False

An abstract class is useful when


Select correct option:
no classes should be derived from it.
there are multiple paths from one derived class to another.
no objects should be instantiated from its.
you want to defer the declaration of the class.

In resolution order compiler search firstly _______.


Select correct option:
Generic Template
Partial Specialization
www.vuplanet.com

Complete Specialization
Ordinary function

template<> class Vector{ void** p; //.... void*& operator[] ((int i); };


Select correct option:
This specialization can then be used as the common implimentation for all Vectors of
pointers.
This spcialization can then be used as the all type implimentation for one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.

In private inheritance derived class pointer can be assigned to base class pointer in,
Select correct option:
Main function
In derived class member and friend functions
In base class member and friend functions
None of the given options

Which statement will be true for concrete class?


it implements an virtual concept.
it can be instantiated
it cannot be instantiated
none of given

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given

The Specialization pattern after the name says that this specialization is to be used for
every___.
Select correct option:
data types
meta types
virtual types
pointers type

c++ dynamic binding and polymorphism will be achieved when member function will be
__.
Select correct option:
www.vuplanet.com

private
public
virtual
inline

Consider the code below, class class1{ protected: void func1(); }; class class2 : public
class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ protected: int i; }; class class2 : protected class1 {
}; Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ private: void func1(); }; class class2 : private class1
{ }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given

Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;


Select correct option:
These statements will compile successfully
Error in first statement
Error in second statement
None of given options
www.vuplanet.com

Consider the code below, class class1{ private: int i; }; class class2 : private class1 { };
Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

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.
Select correct option:
base
derived
virtual
implemented

A class template may inherit from another class template.


Select correct option:
True
False

Derived class can inherit from public base class as well as private and protected base
classes
Select correct option:
True
False

Two functions with same names, parameters and return type can exist in,
Select correct option:
Function overloading
Function overriding
Operator overloading
None of these options

Consider the code below, class class1{ private: int i; }; class class2 : public class1 { }; Then
int member i of class1 is ______ in class2,

Select correct option:


public
protected
private
none of the given options
www.vuplanet.com

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given

A class template may inherit from another class template.


Select correct option:
True
False

A function call is resolved at run-time in_________


Select correct option:
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given
hello

A class hierarchy
Select correct option:
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.

Consider the code below, class class1{ public: int i; }; class class2 : public class1 { }; Then
int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then
c1 is,
Select correct option:
Direct base class of c3
Direct child class of c3
Direct base class of c2
Direct child class of c2
www.vuplanet.com

A class can inherit from more then one class is called.


Select correct option:
Simple inheritance
Multiple inheritances
Single inheritance
Double inheritance

template<> class Vector{ void** p; //.... void*& operator[] ((int i); };


Select correct option:

This specialization can then be used as the common implimentation for all Vectors of
pointers.
This spcialization can then be used as the all type implimentation for one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.

Consider the code below, class class1{ public: int i; }; class class2 : protected class1 { };
Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ private: void func1(); }; class class2 : public class1
{ }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Templates automatically create different versions of a function, depending on user


input.
Select correct option:
True
False

_________ Binding means that target function for a call is selected at run time
Select correct option:
Automatic
Dynamic
Static
Dramatic
www.vuplanet.com

When we create objects, then space is allocated to:


Member function
Access specifier
Data member
None of given

There is only one form of copy constructor.


True
False

Which of the following features of OOP is used to deal with only relevant details?
Abstraction
Information hiding
Object

____________ Binding means that targets function for a call is selected at compile time.
Static
Dynamic
Automatic
None of given

A Class hierarchy
Shows the same relationships as an organization chart
Describes “has a” relationships.
Describes “is a kind of” relationships.
Shows the same relationships as a family tree

In C++, we declare a function virtual by preceding the function header with keyword
“Inline”
True
False

It is illegal to make objects of one class members of another class.


True
False

In Resolution order compiler search firstly____________.


Generic Template
Partial Specification
Complete Specification
Ordinary function
www.vuplanet.com

Derived class can inherit from public base class as well as private and protected base
classes
True
False

Which line will produce error. Class phone: Private Transmit, private Receiver { } 1.int
main () 2. { 3.phone obj; 4.Tranmit*obj1 = &obj; 5.Received obj2 = &obj; 6.}

3rd line will produce error


4th line will produce error
3rd and 4th line will produce error.
5th line will produce error.

Methodologies to the development of reusable software relate to ____________.


Structure programming
Procedural programming
Generic programming
None of the given

A template argument is preceded by the keyword__________.


Vector
Class
Template
Type*

Friends are used exactly the same for template and non-template classes.
True
False

A function template must have a parameter


True
False

Child class can call constructor of its,


Direct base class
Indirect base class
Both direct and indirect base classes
None of these.

Which statement will be true for concrete class?


It implements an virtual concept.
www.vuplanet.com

It can be instantiated
It cannot be instantiated
None of given

A class D can be derived from a class C, which is derived froma class B, which is derived
from a class A
True
False

Adding a derived class to a base class requires fundamental changes to the base class.
True
False

A Class or class template can have member ___________ that are themselves
templates.

Variable
Function
Objects
None of given

Which will be the Primary task or tasks of generic programming?


Categorize the abstractions in a domain into concepts
Implement generic algorithms based on the concepts
Build concrete models of the concepts
All of given

The default inheritance mode is,


Public inheritance
Protected Inheritance
Private Inheritance
None of these options

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.
Base
Derived
Virtual
Implemented

A class template ____________


Facilitates reuse of class
www.vuplanet.com

Does not facilitate reuse of class

Sender of the message does not need to know the exact class of receiver in________.
Abstraction
Polymorphism
Inheritance
none of the given

Friend Functions of a class are _________ members of that class.


Select correct option:
Public
Private ---
Protected
None of the given options.

Consider the code below, class class1{ protected: int i; }; class class2 : protected class1 {
}; Then int member i of class1 is ______ in class2,
Select correct option:
public
protected
private
none of the given options

A Child class can call constructor of its parent class through,


Select correct option:
Its constructor initialization list
Its constructor body
Both from its constructor initialization list or body --------
Can not call the constructor of its parent class

We can access private members of the class from outside the class using ______
operator with its object pointer.
Select correct option:
->
.
&
None of the given options

A function call is resolved at run-time in___________


Select correct option:
non-virtual member function
www.vuplanet.com

virtual member function


Both non-virtual member and virtual member function.
None of given

It is sometimes useful to specify a class from which no objects will ever be created.
Select correct option:
True
False

Consider the code below, class class1{ public: void func1(); }; class class2 : private class1
{ }; Function func1 of class1 is ______ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ public: int i; }; class class2 : protected class1 { };
Then int member i of class1 is ______ in class2,
Select correct option:
public
protected
private
none of the given options

Static casting is,


Select correct option:
Implicit way of calling base class functions from derived class
Explicit way of calling base class functions from derived class
None of these
Both of these

Consider the code below, class class1{ protected: void func1(); }; class class2 : public
class1 { }; Function func1 of class1 is ______ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ public: void func1(); }; class class2 : public class1 {
}; Function func1 of class1 is ______ in class2
Public
www.vuplanet.com

Protected
Private
none of the given options

Consider the code below, class class1{ protected: int i; }; class class2 : public class1 { };
Then int member i of class1 is ______ in class2,
public
protected
private
none of the given options

In Private Inheritance the public members of base class become __________ in derived
class.
Public
Private
Protected
None of the given options.

Consider the following two lines of code written for a class Student, 1. Student sobj1; 2.
Student sobj2(sobj1); In line No.2 what constructor of Student class will be called,
Default constructor of Student class
Copy constructor of student class
Both default and copy constructer of Student class
No constructor will be called
Cs-304 Important Macq’s For Final Term:
Solve By Vu_Toper-RM

All Paid Services Is Available !! VU


LMS Handling + Notes+
Online Classes + Project

Nothing Is Impossible >> O3224021365


Methodologies to the development of reusable software relate to
a) Structure programming
b) Procedural programming
c) Generic programming
d) None of the given
In case of template specialization, if compiler
cannot find required complete specialization, t
a. General template
b. Complete template
c. Partial specialization
Which of the following may inherit form the
ordinary class?
a. Class template
b. Partial specialization
c. Complete specialization
d. All of given option
Which of the following is not type of
inheritance in c++?
a) Public
b) Protected
c) Restricted
Which of the following statement is true about
partial specialization?
a. Function templates cannot have partial
specialization
b. Class template cannot have partial
specialization
c. Both class templates and function
template can have partial specialization. d.
None of the given
In resolution order of function template,
compiler searches for in the end
a. Complete specialization
b. Partial specialization
c.Generic template
Which of the following is known as
Dereference operator in C++?
a. +
b. *
c. &
When we want to have exactly identical
operations on different data type, are used
a. Function Template
b. Function Overloading
c. Function Overriding
When we specialize a function template, it is
called
a. Function overloading
b. Function overriding
c. Function template overloading
A class template may inherit from another class template.
True
False
Target of a _____ function call is determined at run time.
instance
virtual
operator none of given
Sender of the message does not need to know the exact class of
receiver in______.
Abstraction
Polymorphism
A function call is resolved at run-time in_________ .
non-virtual member
function virtual member
function
Both non-virtual member and virtual member function.
User can make virtual table explicitly.
True
False
Binding means that target function for a call is selected at
compile time.
Static
Dynamic
Which line will produce error. Class phone: private Transmit,
private Receiver { } 1. int main() 2. { 3. phone obj; 4. Tranmit*
obj1 = &obj; 5. Received obj2 = &obj; 6.
}.
3rd line will produce error
4th line will produce error
3rd and 4th line will produce error.
5th line will produce error
Function overriding is done in context of,
Single class
Derived and base classes
Methodologies to the development of reusable software
relate to________.
Structure programming
generic programming
Function template must have a parameter.
True
False
The default inheritance mode is,
Public inheritance
Private inheritance
None of these options
Two functions with same names, parameters and return type can
exist in,
Function overloading
Function overriding
Consider the code below, class c1{ }; class c2 : public c1 { };
class c3 : public c2 { }; Then c2 is,
Direct base class of c3
Direct child class of c3
User can make virtual table explicitly.
True
False
In order to define a class template the first line of definition
must be:
template <typename T>
typename <template T>
Consider the following statements: 1) int iArray[5]; 2) int
*pArr = iArray;
These statements will compile successfully
Error in second statement
In type in depended function template should be use where
code and behavior must be identical.
True
False
It is illegal to make objects of one class members of another
class.
True
False
In resolution order compiler search firstly _______.
Complete Specialization
Ordinary function
template<> class Vector {void** p; //.... void*& operator[]
((int i); };
This specialization can then be used as the common
implementation for all Vectors of pointers.
This specialization can then be used as the all type
implementation for one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int
types.
Consider the code below, class class1{ private: int i; };
class class2 : private class1 { }; Then int member i of
class1 is ____ in class2, public protected
private
none of the given options
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.
base
derived
A class template may inherit from another class template.
True
False
Derived class can inherit from public base class as well as
private and protected base classes
True
False
Consider the code below, class class1{ private: int i; }; class
class2 : public class1 { }; Then int member i of class1 is ____
in class2,
None of the given
options
Binding means that
target function for a
call is selected at run
time
Automatic
Dynamic
When we create objects, then space is allocated to:
Member function
Access specifier
Data member
None of given
There is only one form of copy constructor.
True
False
Which of the following features of OOP is used to deal
with only relevant details? Abstraction
Information hiding
Object
___________ Binding means that targets function for a call is
selected at compile time. Static
Dynamic
Automatic
None of given
A Class hierarchy
Shows the same relationships as an organization
chart Describes “has a” relationships.
Describes “is a kind of” relationships.
Shows the same relationships as a family tree
In C++, we declare a function virtual by preceding the
function header with keyword “Inline”.
True
False
It is illegal to make objects of one class members of another
class.
True
False
Derived class can inherit from public base class as well as
private and protected base classes
True
False
Which line will produce error? Class phone: Private
Transmit, private Receiver { }
1.int main () 2. { 3.phone obj; 4. Transmit*obj1 = &obj;
5.Received obj2 = &obj; 6.}
3rd line will produce
error 4th line will
produce error
3rd and 4th line will
produce error. 5th line will
produce error.
Methodologies to the development of reusable software
relate to ____.
Friends are used exactly the same for template and non-
template classes.
True
False
A function template must have a parameter
True
False

Child class can call constructor of its,


Direct base class
Indirect base class
Both direct and indirect base
classes None of these.
Which statement will be true for concrete class?
It implements an virtual concept.
It can be instantiated
It cannot be instantiated
None of given

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


from class B, which is derived from a class A
True
False
Adding a derived class to a base class requires fundamental
changes to the base class.
True
False
A Class or class template can have member ___________
that are themselves templates.
Variable
Function
Objects
None of given
Which will be the Primary task or tasks of generic
programming?
Categorize the abstractions in a domain into concepts
Implement generic algorithms based on the concepts
Build concrete models of the
concepts
All of given
The default inheritance mode is,
Public inheritance
Protected Inheritance
Private Inheritance
None of these options

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.
Base
Derived
Virtual
Implemented
Child class can call constructor of its,
Direct base class
Indirect base class
Both direct and indirect base classes
None of these

A pure virtual function is a virtual


function that
causes its class to be abstract.
returns nothing. is
used in a derived
class. takes no
arguments.

1: Consider the code below, class class1{ protected: int i; };


class class2 :
protected class1 { }; Then int member i of class1 is ______ in
class2,
 public

 protected

2: By default, assignment operator (=) performs,


 Shallow copy

 Deep copy

3: The default inheritance mode is,


 Public inheritance

4: In case of dynamic memory allocation in our class we


should use
 Default assignment operator

 copy constructor

5: Static casting is,?


 Implicit way of calling base class functions from derived

class
 Explicit way of calling base class functions from derived

class
6: In case of dynamic memory allocation in a class we should
use,
 User defined default constructor
 user defined copy constructor (true)
7: Which of the following types of Inheritance is used to model
“Implemented in terms of” relationship?
 Public

 private (true)

8: Virtual functions allow you to


 create an array of type pointer-to-base class that can hold

pointers to derived classes.


 group objects of different classes so they can all be

accessed by the same function code. (true)


9: A class D can be derived from a class C, which is derived
from a class B, which is derived from a class A.
 T (true ans)

 F

10: Function overriding is done in context of,


 Explicit way of calling base class functions from derived

class
 None of these

 both 1 and 2

1.An abstract class is useful when


a. no classes should be derived from it.
b.there are multiple paths from one derived class to another.
c. no objects should be instantiated from its.
d. you want to defer the declaration of the class.

2.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 <Class Name>
d Class <Template T>

3. Select correct line of code for composition relationship between


“Keyboard” class and “Keys” class
a class keyboard {Keys type;};
b class keys {KeyBoard type; };
c class keyboard: private keys
d class keys: private KeyBoard

4. Select correct line of code for inheritance relationship between


“Keys” class and “Special Keys” class. “Keys” is parent class while
“Special Keys” is child class
A class Special Keys: public Keys
B class Keys: public Special Keys
C class Special Keys: public Keys
D class Keys: public Special Keys

5 Methodologies to the development of reusable software relate


to__________.
A Structure programming
B procedural programming
C generic programming
D None of the given

6 User can make virtual table explicitly.


A True
B false

7 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
8 Derived class can inherit from public base class as well as private
and protected base classes
A true
B false

9 Which of the following function can convert a class into an abstract


class?
A Abstract function
B Concrete function
C Virtual function
D Pure virtual function

CS304 Question No: 2


Which of the following causes run time binding?
Declaring object of abstract class
Declaring pointer of abstract class
Declaring overridden methods as non-virtual
None of the given

CS304 Question No: 3


A function template can not be overloaded by another
function template.
True
False

CS304 Question No: 4


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?
Templates
Overloading
Data hiding
Encapsulation
CS304 Question No: 5
Identify the correct way of declaring an object of user
defined template class A for char type members?
A obj;
A obj;
A obj;
Obj A;

CS304 Question No: 6


The user must define the operation of the copy constructor.
True
False

CS304 Question No: 7


Template functions use _________ than ordinary functions.
Greater Memory
Lesser Memory
Equal Memory
None of the given options

CS304 Question No: 8


The find() algorithm
finds matching sequences of elements in two containers.
finds a container that matches a specified container.
takes iterators as its first two arguments.
takes container elements as its first two arguments.

CS304 Question No: 9


Compiler performs ________ type checking to diagnose type
errors,
Static
Dynamic
Bound
Unbound

CS304 Question No: 10


Which of the following is/are advantage[s] of generic
programming?
Reusability
Writability
Maintainability
All of given

CS304 Question No: 11


Vectors contain contiguous elements stored as a[an] ___.
variable
array
function
datatype

CS304 Question No: 12


Suppose you create an uninitialized vector as follows:
vector eve;
After adding the statement,
eve. pushback (21);
what will happen?
The following statement will add an element to the start (the
back) of evec and will initialize it with the value 21.
The following statement will add an element to the center of eve
and will reinitialize it with the value 21.
In a de-queue, (chose the best option)
data can be quickly inserted or deleted at any arbitrary location.
data can be inserted or deleted at any arbitrary location, but the
process is relatively slow.
data cannot be quickly inserted or deleted at either end.
data can be inserted or deleted at either end, but the process
is relatively slow.

CS304 Question No: 14


Algorithms can only be implemented using STL containers.
True
False

CS304 Question No: 15


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

CS304 Question No: 16


Inheritance is a way to
organize data.
pass arguments to objects of classes.
add features to existing classes without rewriting them.
improve data-hiding and encapsulation.
CS304 Question No: 17
We can use "this" pointer in the constructor in the body and
even in the initialization list of any class if we are careful,
True
False

CS304 Question No: 18


________ and ______ methods may not be declared abstract.
private, static
private, public
static, public
none of given

CS304 Question No: 19


Default constructor is such constructor which either has no -
--------or if it has some parameters these have -------- values
Parameter, temporary
Null, Parameter
Parameter, default
none of the given

CS304 Question No: 20


Public methods of base class can --------- be accessed in its
derived class
directly
indirectly
simultaneously
none of the given

CS304 Question No: 21


The type that is used to declare a reference or pointer is
called its ---------
default type
static type
abstract type
reference type

CS304 Question No: 22


------------- members are somewhere between public and
private members. They are used in inheritance
protected
public
private
global

CS304 Question No: 23


Which of these are examples of error handling techniques ?
Abnormal Termination
Graceful Termination
Return the illegal
all of the given

CS304 Question No: 24


----------------- follow try block to catch the object thrown.
catch block
throw block
main block
non of the given

CS304 Question No: 25


Graphical representation of the classes and objects is called
object model it shows -------
Class Name only
Class Name and attributes
Relationships of the objects and classes
all of the given

CS304 Question No: 26


Destructor can be overloaded
True
False

CS304 Question No: 27 (M - 2)


Describe the way to declare a template function as a friend
of any class.
Template name
Class classmate
{
Friend void friend template name (class name gastric const part
class name);
}

CS304 Question No: 28 (M - 2)


State any two reasons why the virtual methods cannot be
static?
1-virtual method can not be static as it is dynamic

You might also like