0% found this document useful (0 votes)
10 views42 pages

CS304 Mid Term by JUANID

Uploaded by

emiqueen6464
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)
10 views42 pages

CS304 Mid Term by JUANID

Uploaded by

emiqueen6464
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/ 42

AL-JUNAID INSTITUTE GROUP

SR MCQS QUESTION ANSWER


NO
1 In expression c1*c2+c3-c4 which of the C1*c2
following will be executed in first order
2 Inheritance is a way to Add features to existing
classes without
rewriting them
3 --------------- represent “IS A ”relationship Inheritance
4 Constructor without any parameter is Default constructor
called:
5 Which of the following stores the address Pointer
of a variable?
6 A Post-fix unary operator is implemented 1 dummy int argument
in C ++ using Member function with
7 minimum classes required in a program 3
for implementing multiple inheritance
8 Which of the following statement(s) All of the given option
describe constant member functions?
9 composition is a strong relation Composed object cant
relationship because exist independency
10 How many interactions are there in the 3
following scenario Imran has the car. he
drive the car and car has four wheels and
doors
11 if we extend our model ,and the rest of Flexibility
the model is not affected then it is called-
-----
12 choose correct declaration of Complex and
overload*=1 operator for class complex operator*=(const
as Member function complex & c)
13 Consider the following class A{int a,b,c; A,b,c
public: A():B(10),C(0)a(7) };

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

143 in class B inherits from class A then it class A


contains all characteristics of----
144 which of the following is not an example car
of multiple inheritance
145 which of the following can be created static data members
without any object of a class?
146 consider the following code segment junk value,5, junk value
class test{int a;int b;int c;}
147 object orientation approach can be interactions
achieved using objects and their-----
148 member functions defined inside a class private
declaration are------- by default
149 how can we identify classes from a given by extracting nouns
problem statement from problem
statement
150 which of the following statement is not static variable belongs
true about static variable of a class? to particular instance of
a class
151 there are------ types of constructor in C++ 3
152 statement yasir is a friend of Ali and Ali is two way Association
a friend of yasir is an example of
153 this pointer cannot be passed implicitly static member
to-------- functions
154 which of the following issues can be all of the given
caused by the use of friend function

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

Which part of an object exhibits its state?

► Data (Page 23)

► Operations

► Any public part

► Any private part

Question No: 2

Inheritance is a way to

pg. 13 0304-1659294
AL-JUNAID INSTITUTE GROUP
► 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: 3

Suppose you have been given the following design,

"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

include when you design the patient class?

► registration date and diagnosis

► age and sex

► sex and diagnosis

► diagnosis and age

Question No: 4

What problem(s) may occur when we copy objects without using deep copy constructor?

► Dangling pointer

► Memory Leakage

► All of the given (Page 147)

► System crash

Question No: 5

this pointers are not accessible for static member functions.

pg. 14 0304-1659294
AL-JUNAID INSTITUTE GROUP
► True (Page 114)

► False

Question No: 6

A static member function cannot be declared.

► Static

► Implicit

► Explicit

► Virtual

Question No: 7

___ remain in memory even when all objects of a class have been destroyed.

► Static variables (Page 111)

► Instance variable

► Primitive variables

► None of given

Question No: 8

Friend functions are _____ functions of a class.

► None of given

► object member

► non-member (Page 136)

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

► Friendship is one way only

► Friendship is two way only

► NO Friendship between classes

► Any kind of friendship

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

Where Rational_number_1 is an object of user defined class Rational_number.

► Rational_number operator+( Rational_number & obj);

► Rational_number operator+(double& obj); (Page 145)

► Rational_number operator+(Rational_number &obj, double& num);

► operator+(double& obj);

Question No: 12

pg. 16 0304-1659294
AL-JUNAID INSTITUTE GROUP
Which operator can not be overloaded?

► The relation operator ( >= )

► Assignment operator ( = )

► Script operator ( [] )

► Conditional operator (? : ) (Page 141)

Question No: 13

To convert from a user-defined class to a basic type, you would most likely use

► a built-in conversion operator.

► a one-argument constructor.

► an overloaded = operator.

► a conversion operator that’s a member of the class.

Question No: 14

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

called

----------------

► structured programming

► object oriented Programming (Page 9)

► procedural programming

► non of the given

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

A C++ class is similar to --------------------

► Structure

► Header File

► Library File

► None of the given

Question No: 17

What problem(s) may occur when we copy objects without using deep copy constructor?

► Dangling pointer

► Memory Leakage

► All of the given (Page 147)

► System crash

Question No: 18

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

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

► Instantiated C++ How to Program, Fifth Edition(Page 871)

► 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

Where Rational_number_1 is an object of user defined class Rational_number.

► Rational_number operator+( Rational_number & obj);

► Rational_number operator+(double& obj); (Page 145)

► Rational_number operator+(Rational_number &obj, double& num);

► operator+(double& obj);

Question No:21

____ provide the facility to access the data member.

pg. 19 0304-1659294
AL-JUNAID INSTITUTE GROUP
► accesser function (Page 68)

► private function

► inline function

► None of the given

Question No: 22

Constant objects cannot change their state,

► True (Page 105)

► False

Question No: 23

The ____ relationship indicates that an object contains other objects.

► None of given (Page 53)

► ‘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

► Inheritance (Page 25)

pg. 20 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 25

___ is a relationship

► Inheritance (Page 25)

► Polymarphism

► abstraction

► encapsulation

Question No: 26

____ satisfy the condition of polymorphism

► Carbon

► Diamond

► Coal

► all of the given (Page 56)

Question No: 27

A generalization-specialization relation between classes are implemented using

► data hiding

► friend classes

► encapsulation

► inheritance (Page 49)

Question No: 28

The >= operator can be overloaded.

pg. 21 0304-1659294
AL-JUNAID INSTITUTE GROUP
► True (Page 140)

► False

Question No: 29

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

► Constructor

► Destructor (Page 92)

► Shallow Copy

► Deep Copy

Question No: 30

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

► Mermaid

► Woman (Lecture No.5)

► None of the given

► Amphibious Vehicle

Question No: 31

Static variable can be initialized more than once.

► 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

important feature in oop called --------

► Inheritance (Page 26)

► 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

►Destructor (Page 92)

Question No: 35

Using encapsulation we can achieve

pg. 23 0304-1659294
AL-JUNAID INSTITUTE GROUP
►Information hiding (Page 16)

►Least interdependencies among modules

►Implementation independence

►All of given options

Question No: 36

Inheritance is a way to

►make general classes into more specific classes. (Page 27)

►pass arguments to objects of classes.

►improve data hiding and encapsulation.

►providing class growth through natural selection.

Question No: 37

Static variable can be initialized more than once.

 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

►Base class (Page 29)

►Deprived Class

►Named class

pg. 24 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 39

Which of the following are an advantage of OOP?

►OOP makes it easy to re-use the code

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

►All of the given options Click here for detail

Question No: 40

The >= operator can be overloaded.

►True (Page 140)

►False

Question No: 41

A static member function cannot be declared.

►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

A C++ class is similar to --------------------

►Structure

►Header File

►Library File

►None of the given

Question No: 46

Which operator can not be overloaded?

►The relation operator ( >= )

►Assignment operator ( = )

►Script operator ( [] )

►Conditional operator (? : ) (Page 141)

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

A generalization-specialization relation between classes are implemented using

►data hiding

►friend classes

►encapsulation

►inheritance (Page 49)

Question No: 49

In OOP a class is an example of ___

►Data Type

►Abstract Type

►User Defined Type (Page 66)

►None of the given

Question No: 50

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

►Noun (Page 58)

►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

►Public Member (How to Program page 983)

►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()

► Both Name and Age (page 13)

Question No: 53

What a derived class can add?

► New data members

► New member functions and New friend functions

► New constructors and destructor

► All of given

Question No: 54

____ is/are used to access information hidden within an object?

► Interface

► Private data members

► Private member functions (Page 69)

► Both public and private members

pg. 28 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 55

this pointers are not accessible for static member functions.

► True (Page 14)

► False

Question No: 56

A static member function cannot be declared.

► Static

► Implicit

► Explicit

► Virtual

Question No: 57

C++ compiler does not allow to dynamically allocate memory for objects

► False

► True

Question No: 58

Given the following class

class Base{

int Age=33;

How you can improve above class with respect to accessing the field Age?

► Define the variable Age as private

► Define the variable Age as protected

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

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

►/

►-

►+

► ++

Question No: 61

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

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

correctly, if the overloaded - operator must

► take two arguments.

► return a value

► create a named temporary object.

► take four arguments

Question No: 63

Which operator can not be overloaded?

► The relation operator ( >= )

► Assignment operator ( = )

► Script operator ( [] )

► Conditional operator (? : ) (Page 141)

Question No: 64

We achieve independence of internal implementation from its external interface through-----------

► Encapsulation

► Information Hiding

► Abstraction

► both encapsulation and information hiding

Question No: 65

Which one of the following is not an object association?

pg. 31 0304-1659294
AL-JUNAID INSTITUTE GROUP
► Simple Assocation

► Inheritance (Page 49)

► 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

What a derived class can add?

► New data members

► New member functions and New friend functions

► New constructors and destructor

► All of given

Question No: 68

The concept of derived classes is involved in,

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

► Ask for the option of WindowsPC to be removed as it will soon be obsolete

► Change the hierarchy to remove the need for the superfluous Computer Class.

Question No: 70

Consider the code below,

class Fred {

public:

Fred();

pg. 33 0304-1659294
AL-JUNAID INSTITUTE GROUP
...

};

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

► 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

Question No:71

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

► Destructor of the class

► New operator

► Delete operator

► Constructor of the class

Question No: 72

pg. 34 0304-1659294
AL-JUNAID INSTITUTE GROUP
this pointers are not accessible for static member functions.

► True (Page 14)

► False

Question No: 73

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

► Can not access this variable

► None of given

Question No: 74

___ remain in memory even when all objects of a class have been destroyed.

► Static variables (Page 111)

► Instance variable

► Primitive variables

► None of given

Question No: 75

Given the following class

class Base{

int Age=33;

How you can improve above class with respect to accessing the field Age?

► Define the variable Age as private

► Define the variable Age as protected

► Define the variable Age as private and create a get method that returns it and

a set method that updates it

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

► Aggregation (Page 134)

► Separation

► None of the given

Question No: 77

Which one is not keyword in C++?

► operator

► B_op

► const

► None of given

Question No: 78

The >= operator can be overloaded.

► True (Page 140)

► False

pg. 36 0304-1659294
AL-JUNAID INSTITUTE GROUP
Question No: 79

A template provides a convenient way to make a family of

► variables and data members

► functions and classes

► classes and exceptions

► programs and algorithms

Question No: 80

Which one of the following terms must relate to polymorphism?

► Static allocation

► Static typing

► Dynamic binding (How to program , page 1103)

► Dynamic allocation

Question No: 81

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 257)

► The compiler can only generate copy for the int type data

► None of the given.

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

exactly same functionality and implemented on different data types?

► Templates

► Overloading

► Data hiding

► Encapsulation

Question No: 83

template <>

class Vector<char*> { }

This is an example of partial specialization.

► True (Page 281)

► False

Question No: 84

Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete, while

classes like Sphere and Cube would normally be abstract.

► True

► False Click here for Detail

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

► public members of Derv.

► protected members of Derv.

► private members of Derv.

► protected members of Base.

Question No: 87

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

► template <typename T> (Page 281)

► typename <template T>

► Template Class <ClassName>

► Class <Template T>

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

► virtual (not sure)

Question No: 89

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 (Page 204)

Question No: 90

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

► All

► One specific

► All instances of one date type

► None of the given options

Question No: 91

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.

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

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.

Question No: 93

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

► State

► Behavior

► Protected data members

► All of given (not sure)

Question No: 94

Which is not the Advantage of inheritance?

► providing class growth through natural selection.

► facilitating class libraries.

► avoiding the rewriting of code.

► providing a useful conceptual framework

pg. 41 0304-1659294

You might also like