CS304 Mid Term by JUANID
CS304 Mid Term by JUANID
pg. 1 0304-1659294
AL-JUNAID INSTITUTE GROUP
14 Class is a blue print of Objects
15 Suppose we have a class student which Student*object
of the following statement is correctly
declaring the pointer to the object of
student class?
16 In c++ composition is relationship Whole, part
between -------and------objects
17 Which of the following Depicts the a class is description of
proper definition of class? a kind of object
18 in class attributes are represented by ---- data member, Member
and------ respectively function
19 which of the following represents the Employee works for the
two Association company
20 Entities in OO model are represented by Rectangle
21 Which of the following features of OOP is Inheritance
used to derive a class from another?
22 In C ++ which of the following is defined <<
as a stream insertion operator?
23 choose the correct declaration of Bool operator==(const
overloaded equality (==)operator for string and s)
class string as a Member function
24 ---- is the relationship between the part Composition
object and the whole object
25 object hides its information from others information hiding
this concept is known as
26 the concept of derived classes is involved Inheritance
in
27 abstraction provides information user perspective
according to
28 which of the following is not an object Inheritance
Association
29 which of the following classes are used both land and water
by amphibious vehicle to inherit vehicle
characteristics
pg. 2 0304-1659294
AL-JUNAID INSTITUTE GROUP
29 object data includes both states and
attributes of an object
30 choose correct declaration of overloaded friend pool operator
inequality operator for class string as non !=(const string
member friend function &s1,const string &2)
31 How many objects of a given class may as many as the
be constructed in an application? application ask for
32 how many objects of a given class may be as many as the
constructed in an application application ask for
33 Which of the following statements all of the given option
describe constant member functions?
34 student *ptr=new student(" Ali"); is an static memory
example of allocation
35 in------- base class can be replaced by the extension
derived class
36 Which of the following is a correct way of cosnst int Roll no;
declaring constant variable ROLLNO?
37 which of the following operator doesn't none of the given
take argument hit overloaded choices
38 which of the following is part of the Class all of the given option
diagram
39 a child inherits characteristic from its parent
40 which of the following issues can be programming Bugs
caused by the use of friend function
41 which of the following is not true about all of the given option
constant number function
42 Which one is not the main features of exception handling
object oriented programming?
43
44 in object oriented programming, objects messages
communicate with each other through
45 static data member is declared inside the class
46 the concept of derived classes is involved inheritance
in
pg. 3 0304-1659294
AL-JUNAID INSTITUTE GROUP
47 Which of the following can we attribute address
of an object "Ali"?
48 Which of the following keyword tell the inline
compiler to substitute the code within
the function definition for every instance
of a function call?
49 inheritance is the relationship between classes
50 how many objects are involved in the 2
binary Association
51 all objects of same class has -------- same
attributes
52 which of the following concept is more information hiding
close to encapsulation
53 member initialization list is used to initialize data member
54 aggregation between objects show that objects have week
relationship
55 there is /are ways to create user defined two
types for objects in C ++
56 composition is a strong relationship composed object can
because: not exist independently
57 in polymorphism messenger can be receiver
interpreted in different ways depending
upon the----- class
58 which of the following is most suitable simplifies the model
advantage of information hiding
59 the process of extracting common Generalization
characteristics from two or More classes
and combining them into a generalized
superclass is called
60 ------- operator is used to create objects new
at run time
61 choose the correct option to declare an friend out stream and
overloaded Stream insertion operator for operator<<(ostream
and os,const string & s)
pg. 4 0304-1659294
AL-JUNAID INSTITUTE GROUP
userdefind class "string" as a non-
member friend function
62 static data member is declared inside the class
63 an instance of user defined type is called object
64 which of the following is true about all of the given option
constructor
65 Which of the following correct way of const int ROLLNO;
declaring constant variable ROLLNO?
66 inheritance is shown by filled arrow
67 which of the following operators operate unary operator
on one operand
68 which of the following will happen when compile time error will
a constant function tried to change the occur
value of data members of the class
69 in object oriented programming, objects messages
communicate with each other through---
70 How the information hidden within an through its interface
object can be accessed?
71 object orientation approach can be interactions
achieved using object and their-------
72 constructors have ----- return type no
73 which of the following is an example of increment operator(++)
unary operator
74 memory is allocated to non-static object is created
members only when
75 in class B inherit from class A which of class B
the following is child class
76 the------ tells the compiler what task the function definition
function will be performing
77 Consider the statement" room has chair" aggregation
which of the following type of
Association exists between whom and
chair?
pg. 5 0304-1659294
AL-JUNAID INSTITUTE GROUP
78 how many objects are involved in the N- more than 3
ary Association
79 deconstruct is a function which has the ~
same name as that of class but starts
with a----- sign
80 which of the following is a tangible entity car
81 member initializer list is used to initialize data members
82 we can get the address of variable stored & symbol
in pointer using-----
83 two sentence object oriented aggregation
programming book in bookshelf is an
example of
84 which of the following best defines the hide the
obstruction implementation and
show current
perspective
85 which of the following define default student(){//..}
constructor 5 class student
86 object data includes both state and
attributes of an object
87 minimum classes required in a program 3
for implementing multiple inheritance
88 information hiding can be achieved encapsulation,
through------- abstraction
89 compiler generated defaulter structure is implicit, explicit
called----- hand user written default
constructor is called----
90 which of the following is true about all of the given option
constructor
91 In which of the following different forms polymorphism
office single entity exist?
92 data members of a class student can be: all of the given option
93 the----- turn off the compiler what does function definition
the function will be performing
pg. 6 0304-1659294
AL-JUNAID INSTITUTE GROUP
94 Suppose a class does not have any compiler will call
constructor what will happen when an implicit default
object of this class is created? constructor
95 how can we differentiate between destructor are preceded
constructor and destructor with a Tilda(~) symbol,
and constructor are not
preceded with any
symbol
96 ---- is used for hiding the details of an encapsulation
object from the other parts of a program
97 Class diagram include class name, attributes,
operation
98 through interface was access objects------ behavior
--
99 composition is a strong relationship compose object cannot
because exist independently
100 copy constructor is called when: an object is created in
term of Preexisting
object
101 choose the correct option to declare an friend ostream &
overloaded stream insertion operator for operator(ostream
a user defined class string as a non- &os.const string &s)
Member friend function
102 a post-fix unary operator implemented in two
C plus plus using non Member function
with---- arguments
103 in class attributes and behaviors are data members, member
represented by---- and--- respectively functions
104 which of the following best describes the composition
relationship between book and book
chapter classes
105 which of the following is true about all of the given option
destructor
106 in composition----- are called from destructors
composing objects to composed subjects
pg. 7 0304-1659294
AL-JUNAID INSTITUTE GROUP
107 which of the following can be used an Global variables
alternative to Static members
108 which of the following statement is true it is used to access static
about static function of a class data members
109 which of the following operator does not none of the given
take any arguments if overloaded choices
110 what is the output of the following code error
int main(){int cost
x=10;cout<<++x;return0;}
111 abstraction includes------- relevant information
112 Which of the following can be the eat
behavior of an object "Usman"?
113 a class defined within another class is nested class
114 when an object is initialized, is constructor
automatically called by the compiler
115 the compiler treats the Member function inline function
of a class as
116 an object has attributes operation ,and--- unique identity
----
117 Which of the following is not an access hidden
specifier in C ++?
118 which of the following parts of an object data
exhibits its state
119 ---- is the relationship between the part composition
object and the whole object
120 how can we identify classes from a given by extracting nouns
problem statement from problem
statement
121 what "friend" should be placed in function declaration
122 generalization is-------- approach bottom-up
123 static data members can be accessed dot operator and scope
through-------- resolution operator
124 composition age----- and aggregation is--- strong, weak
---- relationship
pg. 8 0304-1659294
AL-JUNAID INSTITUTE GROUP
125 suppose there is an object of type name
person, which of the following can be
considered as one of its attributes
126 Which of the following depicts the proper a class is a description
definition of class? of a kind of object
127 a child inherits characteristics from its----- parent
--
128 the car is composed of wheels what is composition
the relationship between car and
wheels?
129 ------ is creating objects of one class composition
inside another class
130 the other name of specialization is------- restriction
131 suppose a is an int type static data int test::a=0
member class test then which of the
following is correct way of initialization
the static variable outside the class test
132 Which of the following stores the address Pointer
of variable?
133
134
135 static data member is declared inside the class
136 polymorphism makes the system all of the given option
137 which of the following statement best constructor is used to
describes the constructor initialize the data
members of a class
138 data member(s) of a class student can be all of the given option
139 which of the following is a strong composition
relationship
140 all objects of same class has------- same
attributes
141 in C ++ composition is a relationship whole, part
between----and---- objects
pg. 9 0304-1659294
AL-JUNAID INSTITUTE GROUP
142 suppose 12 class string assignment compiler will generate
compile time error
operator is overloaded with following
declaration void operator=(const string
&); what will happen when we will write
following statement in main()
str=str2=str3;where,str1.str2,str3 are
object of class string
pg. 10 0304-1659294
AL-JUNAID INSTITUTE GROUP
155 in------ send a message does not need to none of the given
know exact class of the receiver option
156 minimum classes required in a program 3
for implementing multiple inheritance
157 -------Associates the object of the exact binary Association
two classes
158 main characteristics of information hiding keep the model simple
is
159 static data member is declared inside the class
160 in expression b=c/d, the arity of 2
division(/) operator is
161 we can allocate dynamic memory in C ++ new
through operator
162 Which of the following is true about all of the given option
accessor functions?
163 in---- base class cannot always be specialization
replaced by the derived class
164 abstraction help to reduce the complexity
165 relationship in which child object gets composition
destroyed if parent object is destroyed
166 object oriented programming is better it is more close to
than procedural programming because: reality
167 The derived class inherits behavior from Overriding
the base class and also exhibits its own
behavior. this concept is known as---
168 the other name of subtyping is Extension
169 A good model is------ related to life closely
problem
170 in generalization general class represents common
the -------- behavior of the class
171 how can we identify from a given by extracting noun from
problem statement? problem statement
172 which of the following is not a access hidden
specifier in C ++
pg. 11 0304-1659294
AL-JUNAID INSTITUTE GROUP
173 in composition------ are called from destructors
composing objects to composed objects
174 a class have only---- destructor one
175 suppose you have following C + + oldVlue=11,newVlue=11
statement int old value=10; int new
value=++old value; what will be the value
of old value and newValue after
executing above statements ?
176 in constant Member function the type of constant pointer to
this pointer is constant data
177 ----- is creating objects of one class inside composition
another class
178 -------- Associates the objects of the exact ternary Association
three classes
179 generalization is implemented through inheritance
180 which of the following is strong composition
relationship
181 composition is a strong relationship composed object
because cannot exist
independently
182 ----- is set of function of an object interface
exposed of other objects
183 suppose student is a class, which of the student(char*aName);
following defines constructor with one
parameter for class student
184 which of the following is not true about all of the given option
constant Member function
185 ----- define the order of evaluation of an operator precedence
operator is an expression
186 choose correct declaration of overloaded friend bool
inequality(!=) operator for class string as operator!=(const string
non member friend function &s1,cont string &s2)
187 which of the following is most suitable simplifies the model
advantage of information hiding
pg. 12 0304-1659294
AL-JUNAID INSTITUTE GROUP
188 a fan has wings, which type of relation composition
exists between fan and Wings in this
sentence
189 multiple inheritance is implemented comma(,)
between class through------ symbol
190 postfix unary operator is implemented in two
C ++ using non Member function with
arguments
191 Supposed derived class is inherited from the constructor of base
base class what happens when a derived class exact is executed
class object is created before the constructor
of derived class
192 assignment operator are right associative
193 a postfix unary operator is implemented 1 dummy int argument
in C ++ using number function with
194 which of the following is true about all of the given option
exception functions
Question No: 1
► Operations
Question No: 2
Inheritance is a way to
pg. 13 0304-1659294
AL-JUNAID INSTITUTE GROUP
► organize data.
Question No: 3
"A person has a name, age, address and sex. You are designing a class to represent a type of person
called a patient. This kind of person may be given a diagnosis, have a spouse and may be alive".
Given that the person class has already been created, what of the following would be appropriate to
Question No: 4
What problem(s) may occur when we copy objects without using deep copy constructor?
► Dangling pointer
► Memory Leakage
► System crash
Question No: 5
pg. 14 0304-1659294
AL-JUNAID INSTITUTE GROUP
► True (Page 114)
► False
Question No: 6
► Static
► Implicit
► Explicit
► Virtual
Question No: 7
___ remain in memory even when all objects of a class have been destroyed.
► Instance variable
► Primitive variables
► None of given
Question No: 8
► None of given
► object member
► data member
Question No: 9
_____, which means if A declares B as its friend it does NOT mean that A can access private data
pg. 15 0304-1659294
AL-JUNAID INSTITUTE GROUP
of B. It only means that B can access all data of A.
Question No: 10
The statement objA=objB; will cause a compiler error if the objects are of different classes.
► True
► False
Question No: 11
Identify which of the following overloaded operator function’s declaration is appropriate for the given
call?
Rational_number_1 + 2.325
► operator+(double& obj);
Question No: 12
pg. 16 0304-1659294
AL-JUNAID INSTITUTE GROUP
Which operator can not be overloaded?
► Assignment operator ( = )
► Script operator ( [] )
Question No: 13
To convert from a user-defined class to a basic type, you would most likely use
► a one-argument constructor.
► an overloaded = operator.
Question No: 14
The technique in which we visualize our programming problems according to real life’s problems is
called
----------------
► structured programming
► procedural programming
Question No: 15
pg. 17 0304-1659294
AL-JUNAID INSTITUTE GROUP
In object orientated programming, a class of objects cans _____ properties from another class
of objects
► Utilize
► Borrow
► Inherit
► Adopt
Question No: 16
► Structure
► Header File
► Library File
Question No: 17
What problem(s) may occur when we copy objects without using deep copy constructor?
► Dangling pointer
► Memory Leakage
► System crash
Question No: 18
Suppose that the Test class does not have an overloaded assignment operator. What happens when an
► Compiler error
pg. 18 0304-1659294
AL-JUNAID INSTITUTE GROUP
► Run-time error
Question No: 19
a’A static member function can be called, even when a class is not ____.
► Declared
► Define
► Called
Question No: 20
Identify which of the following overloaded operator function’s declaration is appropriate for the given
call?
Rational_number_1 + 2.325
► operator+(double& obj);
Question No:21
pg. 19 0304-1659294
AL-JUNAID INSTITUTE GROUP
► accesser function (Page 68)
► private function
► inline function
Question No: 22
► False
Question No: 23
► ‘has-a’
► ‘is-a’
► ‘be-
Question No: 24
Which one of the following features of OOP is used to derive a class from another?
► Encapsulation
► Polymorphism
► Data hiding
pg. 20 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 25
___ is a relationship
► Polymarphism
► abstraction
► encapsulation
Question No: 26
► Carbon
► Diamond
► Coal
Question No: 27
► data hiding
► friend classes
► encapsulation
Question No: 28
pg. 21 0304-1659294
AL-JUNAID INSTITUTE GROUP
► True (Page 140)
► False
Question No: 29
► Constructor
► Shallow Copy
► Deep Copy
Question No: 30
► Mermaid
► Amphibious Vehicle
Question No: 31
► True
► False
pg. 22 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 32
A generic class showing all the common attributes and a behavior of other classes represents a very
► Encapsulation
► Polymarphism
► Abstraction
Question No: 33
We can get only one unique value which can be used by all the objects of that class by the use of,
►static variables
►dynamic variables
►instance variables
►data members
Question No: 34
A member function having the same name as that of a class and a ~ sign with it is called,
►Constructor
►Getter
►Setter
Question No: 35
pg. 23 0304-1659294
AL-JUNAID INSTITUTE GROUP
►Information hiding (Page 16)
►Implementation independence
Question No: 36
Inheritance is a way to
Question No: 37
True
False (Page 107)
Question No: 38
For classes with common behavior, you can save effort by placing the common behavior in a ____.
►Derived Class
►Deprived Class
►Named class
pg. 24 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 39
►It provides an ability to create one user defined data type by extending the other
►It provides the facility of defining Abstract data types through which real world entities can be
defined better.
Question No: 40
►False
Question No: 41
►Static
►Implicit
►Explicit
►Virtual
Question No: 42
Static variables act like a global variable in the context or scope of the class.
►True
►False
Question No: 43
pg. 25 0304-1659294
AL-JUNAID INSTITUTE GROUP
The compiler won’t object if you overload the * operator to perform division.
►True
►False
Question No: 44
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
Question No: 45
►Structure
►Header File
►Library File
Question No: 46
►Assignment operator ( = )
►Script operator ( [] )
Question No: 47
An overloaded operator always requires one less argument than its number of operands.
pg. 26 0304-1659294
AL-JUNAID INSTITUTE GROUP
►True
►False
Question No: 48
►data hiding
►friend classes
►encapsulation
Question No: 49
►Data Type
►Abstract Type
Question No: 50
►Pronoun
►Verb
►Adverb
Question No: 51
The members of a class that can be accessed without creating the object of the class is called
pg. 27 0304-1659294
AL-JUNAID INSTITUTE GROUP
►Private member
►Data Member
►Static
Question No: 52
Suppose there is an object of type Person, which of the following can be considered as one of its
attributes
► Name
► Age
► Work()
Question No: 53
► All of given
Question No: 54
► Interface
pg. 28 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 55
► False
Question No: 56
► Static
► Implicit
► Explicit
► Virtual
Question No: 57
C++ compiler does not allow to dynamically allocate memory for objects
► False
► True
Question No: 58
class Base{
int Age=33;
How you can improve above class with respect to accessing the field Age?
pg. 29 0304-1659294
AL-JUNAID INSTITUTE GROUP
► Define the variable Age as private and create a get method that returns it and a set method that
updates it
► Define the variable Age as protected and create a set method that returns it and a get method that
updates it
Question No: 59
Friend class and friend function can be used as an alternate to each other
► True
► False
Question No: 60
►/
►-
►+
► ++
Question No: 61
Suppose that the Test class does not have an overloaded assignment operator. What happens when an
► Compiler error
► Run-time error
Question No:62
pg. 30 0304-1659294
AL-JUNAID INSTITUTE GROUP
Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1 - obj2 to work
► return a value
Question No: 63
► Assignment operator ( = )
► Script operator ( [] )
Question No: 64
► Encapsulation
► Information Hiding
► Abstraction
Question No: 65
pg. 31 0304-1659294
AL-JUNAID INSTITUTE GROUP
► Simple Assocation
► Aggregation
► Composition
Question No: 66
Keeping in view the principle of abstraction, which of the above information the company needs to save
as employee’s record?
► 2, 4
► 1, 3, 5
► 1, 2, 3 (Lecture No.3)
► 1, 2, 3, 4
Question No: 67
► All of given
Question No: 68
pg. 32 0304-1659294
AL-JUNAID INSTITUTE GROUP
► inheritance (Page 25)
► encapsulation
► structure
► array
Question No: 69
Your chief Software designer has shown you a sketch of the new Computer parts system she is about to
create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is
called LinuxPC and one is called WindowsPC. The main difference between the two is that one runs the
Linux operating System and the other runs the Windows System (of course another difference is that
one
needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one
called Server and one Called Workstation. How might you appraise your designers work?
► Give the goahead for further design using the current scheme
► Ask for a re-design of the hierarchy with changing the Operating System to a field rather than
Class
► Change the hierarchy to remove the need for the superfluous Computer Class.
Question No: 70
class Fred {
public:
Fred();
pg. 33 0304-1659294
AL-JUNAID INSTITUTE GROUP
...
};
int main()
Fred a[10];
...
► Produce an error
Question No:71
► New operator
► Delete operator
Question No: 72
pg. 34 0304-1659294
AL-JUNAID INSTITUTE GROUP
this pointers are not accessible for static member functions.
► False
Question No: 73
When a variable is define as static in a class then all object of this class,
► None of given
Question No: 74
___ remain in memory even when all objects of a class have been destroyed.
► Instance variable
► Primitive variables
► None of given
Question No: 75
class Base{
int Age=33;
How you can improve above class with respect to accessing the field Age?
► Define the variable Age as private and create a get method that returns it and
pg. 35 0304-1659294
AL-JUNAID INSTITUTE GROUP
► Define the variable Age as protected and create a set method that returns it and a get method
that
updates it
Question No: 76
The life of sub object is not dependant on the life of master class in _____.
► Composition
► Separation
Question No: 77
► operator
► B_op
► const
► None of given
Question No: 78
► False
pg. 36 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 79
Question No: 80
► Static allocation
► Static typing
► Dynamic allocation
Question No: 81
► The compiler generates a copy of function respective to each type of data (Page 257)
► The compiler can only generate copy for the int type data
Question No: 82
pg. 37 0304-1659294
AL-JUNAID INSTITUTE GROUP
Which of the following is the best approach if it is required to have more than one functions having
► Templates
► Overloading
► Data hiding
► Encapsulation
Question No: 83
template <>
class Vector<char*> { }
► False
Question No: 84
► True
Question No: 85
pg. 38 0304-1659294
AL-JUNAID INSTITUTE GROUP
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: 86
Assume a class Derv that is privately derived from class Base. An object of class Derv located in main()
can access
Question No: 87
In order to define a class template, the first line of definition must be:
Question No: 88
pg. 39 0304-1659294
AL-JUNAID INSTITUTE GROUP
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
► Derived
► Abstract
Question No: 89
When the base class and the derived class have a member function with the same name, you must be
► dot operator
► null operator
Question No: 90
Non Template Friend functions of a class are friends of ____instance/s of that class.
► All
► One specific
Question No: 91
pg. 40 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 92
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
Question No: 93
► State
► Behavior
Question No: 94
pg. 41 0304-1659294