-->

OOP MCQ UNIT 2 FIRST PAGE




Id 1

Question Polymorphism is supported by the c++ by using following ways

A function overloading

B operator overloading

C virtual functions

D all of the above

Answer D

Marks 1

Unit II


Id 2

Question Compile time polymorphism is supported by

A function overloading

B virtual function

C operator overloading

D both a&c

Answer D

Marks 1

Unit II


Id 3

Question Run time polymorphism is supported by

A function overloading

B operator overloading

C virtual function

D both a and b

Answer C

Marks 1

Unit II


Id 4

Question Selecting the appropriate overloaded function by the compiler is known as

A late binding

B early binding

C both a and b

D none of the above

Answer B

Marks 1

Unit II


Id 5

Question object to function binding is done at compile time then is it known as

A early binding

B compile time bindingC none of the above

D both a and b

Answer D

Marks 1

Unit II


Id 6

Question Run time polymorphism is done by using

A function overloading

B operator overloading

C virtual function

D none of the above

Answer C

Marks 1

Unit II


Id 7

Question Operator overloading is ---.

A run time polymorphism

B compile time polymorphism

C none of the above

D both a and b

Answer B

Marks 1

Unit II


Id 8

Question Which of the following operator cannot be overloaded

A scope resolution operator(::)

B Size of operator (sizeof[])

C Conditional operator(?:)

D All of the above

Answer D

Marks 1

Unit II


Id 9

Question Which of the operator cannot be overloaded

A >=

B &

C <=

D ::

Answer D

Marks 1

Unit II


Id 10

Question While performing operator overloading which function/keyword we have to use

A Function

B Operator

C Op

D none of the above

Answer B

Marks 1

Unit II


Id 11

Question Which of the statement is not true about operator overloading

A we can overload only existing operator

B basic meaning cannot be changed

C binary operator should have return type

D All of the above

Answer D

Marks 1

Unit II


Id 12

Question Pick up the correct statement related with operator overloading

A we can overload a class access operator

B we can change the meaning of basic operator

C binary operator should have a return type

D both a and b

Answer C

Marks 1

Unit II


Id 13

Question We are overloading a unary operator without friend function how many argument we have 

to pass

A 1

B 2

C 0

D none of the above

Answer C

Marks 1

Unit II


Id 14

Question Suppose we are overloading a binary operator with friend function, how many parameter 

of argument we have to pass

A 1

B 2C 3

D none of ths above

Answer B

Marks 1

Unit II


Id 15

Question we are overloading a binary operator without friend function how many argument we 

have to pass

A 1

B 2

C 0

D none of the abve

Answer A

Marks 1

Unit II


Id 16

Question What is polymorphism

A it is ability to take many forms

B it is instance of class

C one class acquire the properties of another class

D All of the above

Answer A

Marks 1

Unit II


Id 17

Question What is true about the operator overloading

A with friend function we need to pass two arguments for binary operator

B with friend function we need to pass one arguments for unary operator

C both a and b

D none of the above

Answer C

Marks 1

Unit II


Id 18

Question ______allows you to give special meaning to some operator when there are operands 

associated with it.

A function overloading

B virtual function

C operator overloading

D none of the above

Answer C

Marks 1Unit II


Id 19

Question Converting from small to larger data type is known as ____.

A promotion

B operator

C polymorphism

D none of the above

Answer A

Marks 1

Unit II


Id 20

Question what are the types of type conversion

A implicit

B explicit

C both a and b

D none of the above

Answer C

Marks 1

Unit II


Id 21

Question Reusability is supported by following feature

A polymorphisms

B message passing

C inheritance

D operator overloading

Answer C

Marks 1

Unit II


Id 22

Question Deriving a new class from a base class is known as __.

A polymorphisms

B inheritance

C message passing

D operator overloading

Answer B

Marks 1

Unit II


Id 23

Question Base class is also known as___.

A super class

B parent classC both a and b

D none of the above

Answer C

Marks 1

Unit II


Id 24

Question Child class is also known as

A sub class

B derived class

C both a and b

D known class

Answer C

Marks 1

Unit II


Id 25

Question Derived class___ cannot access from base class

A constructor

B destructors

C copy constructor

D all of the above

Answer D

Marks 1

Unit II


Id 26

Question we can derive a new class from a derived class

A true

B false

C

D

Answer A

Marks 1

Unit II


Id 27

Question How many parameter does a conversion operator take?

A 0

B 2

C 3

D as many as possible

Answer A

Marks 1

Unit II


Id 28

Question __is used to define pure virtual function?

A &

B =0

C @

D *

Answer B

Marks 1

Unit II


Id 29

Question Which is also known as abstract class?

A virtual function

B pure virtual function

C derived class function

D base class function

Answer B

Marks 1

Unit II


Id 30

Question pick the correct option

A We can make the instance of the abstract class

B We can not make the instance of the abstract class

C both a and b

D none of the above

Answer B

Marks 1

Unit II


Id 31

Question How many access specifiers are there in c++?

A 2

B 3

C 5

D 4

Answer B

Marks 1

Unit II


Id 32

Question Where we have to use an abstract class?

A in base class only

B in derived class only

C both and b

D None of the aboveAnswer A

Marks 1

Unit II


Id 33

Question For what we can apply access

A function

B data member

C none of the above specifier

D both a and c

Answer D

Marks 1

Unit II


Id 34

Question What is default access specifier for class?

A public

B protected

C private

D none of the above

Answer C

Marks 1

Unit II


Id 35

Question We have to define a constructor for the derived class must be required____.

A if base class constructor does not require arguments

B if base/parent class constructor required arguments

C no need

D always

Answer B

Marks 1

Unit II


Id 36

Question Use of the friend function is___.

A the class allowing access to another class

B the private section of a class

C the public section of the class

D all of the above

Answer D

Marks 1

Unit II


Id 37

Question If an attribute is private define then which method can have access to itA only static function

B only functions of that class

C only method in that package

D none of the above

Answer B

Marks 1

Unit II


Id 38

Question What is syntax of deriving a new class from base class is___.

A class name, new class name

B new class name, base class name

C class name: access specifier class name

D none of the above

Answer C

Marks 1

Unit II


Id 39

Question Which constructor will initialize the base class data member

A base class

B derived class

C derived derived class

D none of these

Answer A

Marks 1

Unit II


Id 40

Question Inheritance can be done using :: symbol

A True

B False

C

D

Answer B

Marks 1

Unit II


Id 41

Question When we derived a new class using more than one class then type of inheritance is known 

as____.

A multiple inheritance

B single inheritance

C hybrid inheritanceD multilevel inheritance

Answer A

Marks 1

Unit II


Id 42

Question When class B is derive from A , and class C is derived from B, this kind of inheritance is 

known as ______.

A multiple inheritance

B single inheritance

C hybrid inheritance

D multilevel inheritance

Answer D

Marks 1

Unit II


Id 43

Question The base class will provide you__________.

A specific objects than the derived class

B more generalized version of derived class

C empty template of base class

D all of the above

Answer B

Marks 1

Unit II


Id 44

Question Pick up the correct statement form following

i)we have to use abstract keyword to define the abstract class

ii)inheritance allows multilevel class hierarchies more than two levels also

iii)reusability is supported by derivation

iv) we can change the meaning of operator during operator overloading

A i only

B ii only

C i and ii only

D ii and iii only

Answer D

Marks 2

Unit II


Id 45

Question What does derived class does not inherit from the base class

i)constructor

ii)destructor

iii)operator=()

iv)friendsA i and ii

B ii and iii

C only i, iii and iv

D all of the above

Answer D

Marks 1

Unit II


Id 46

Question Choose the correct the statement from following

i)inheritance supported in terms of single, multiple , multilevel ,hybrid inheritance

ii) polymorphisms is supported by function overloading , operator overloading and 

virtual function

iii) abstraction is not supported by c++

A i is correct

B only ii is correct

C i and ii is correct

D none of the above

Answer C

Marks 1

Unit II


Id 47

Question _____types of classes in c++.

A 1

B 2

C 3

D 4

Answer C

Marks 1

Unit II


Id 48

Question :_______is used to define a pure virtual function.

A $

B ^

C =0

D #

Answer C

Marks 1

Unit II


Id 49

Question Pick up the correct statement

A a base class may have more than one class

B derived class can be derived from more than one classC both a and b

D none of the above

Answer C

Marks 1

Unit II


Id 50

Question class A: public B, public C is a type of inheritance

A Single

B Multiple

C Multilevel

D Hybrid

Answer B

Marks 1

Unit II


Id 51

Question When we have to use the mutable keyword

A data member to change within a const member function

B not allow the data member to change within a const member function

C it will copy the values of the variable

D none of the above mentioned

Answer A

Marks 1

Unit II


Id 52

Question choose the correct statement

A destructor cannot be inherited

B private member not inherited to derived class

C constructor cannot inherited

D a and c

Answer D

Marks 1

Unit II


Id 53

Question Use of function or operator to act different ways on different data type is called as

A derivation

B inheritance

C polymorphisms

D none of the above

Answer C

Marks 1

Unit II


Id 54

Question Choose the correct statement

A Constructor has a return type

B constructor always define in public scope

C constructor has same name that of class name

D b and c

Answer D

Marks 1

Unit II


Id 55

Question overloading of a prefix increment operator by means of a member function 

takes_________.

A one argument

B two argument

C no argument

D none of the above

Answer C

Marks 1

Unit II


Id 56

Question Pick up the correct statement

i)abstract type of class should contain at least one virtual function

ii)we can create an object of abstract class

iii)abstract class is used to provide an interface to subclasses

iv)abstract class can also have normal function

A i and ii only

B i , ii, and iii only

C i ,iii and iv

D all of the above

Answer D

Marks 1

Unit II


Id 57

Question What is function overloading

A we have to use same function name but different parameter

B different function name but same parameter

C both a and b

D none of the above

Answer A

Marks 1

Unit II


Id 58

Question Virtual base class is used to ____.

A to perform operator overloading

B to perform function overloading

C to remove ambiguity in multiple inheritance

D all of the above

Answer C

Marks 1

Unit II


Id 59

Question Pick up the correct statement

A protected member from base class can be accessed by own class and its all subclasses

B protected member are not inherited by any other class

C Protected member are combination of public and private access member

D all of the above

Answer D

Marks 1

Unit II


Id 60

Question pick up the correct statement

A base class and derived class can have their own constructor

B base class and derived class can have their own destructor

C neither a or neither b

D both a and b

Answer D

Marks 1

Unit II

   

 Id 61

Question Make a correct sequence of a statement

i)destructor of derived class is called

ii)destructor of base class is called

iii)constructor of derived class is called

iv)constructor of base class is called

A i,ii,iv,iii

B iv,iii,ii,i

C iv,iii,i,ii

D i,ii,iii,iv

Answer C

Marks 1

Unit II


Id 62

Question Operator overloading is

A making C++ operators work with objects.B giving C++ operators more than they can handle.

C giving new meanings to existing C++ operators.

D Both A and C

Answer D

Marks 2

Unit II


Id 63

Question Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1 - obj2 

to work correctly, the overloaded - operator must

A take two arguments.

B return a value.

C use the object of which it is a member as an operand.

D Both B and C

Answer D

Marks II

Unit 2


Id 64

Question When you overload an arithmetic assignment operator, the result

A goes in the object to the right of the operator.

B goes in the object to the left of the operator.

C goes in the object of which the operator is a member.

D Both B and C

Answer D

Marks 2

Unit II


Id 65

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

A a built-in conversion operator.

B a one-argument constructor.

C an overloaded = operator.

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

Answer D

Marks 1

Unit II


Id 66

Question An overloaded operator always requires one less argument than its number

of operands.

A TRUE

B FALSE

C

D

Answer AMarks 1

Unit II


Id 67

Question The compiler won’t object if you overload the * operator to perform division.

A TRUE

B FALSE

C

D

Answer A

Marks 1

Unit II


Id 68

Question Inheritance is a way to

A make general classes into more specific classes.

B pass arguments to objects of classes.

C add features to existing classes without rewriting them.

D A and C

Answer D

Marks 1

Unit II


Id 69

Question Advantages of inheritance include

A providing a useful conceptual framework.

B facilitating class libraries.

C avoiding the rewriting of code.

D All of the above

Answer D

Marks 2

Unit II


Id 70

Question Adding a derived class to a base class requires fundamental changes to the base class.

A TRUE

B FALSE

C

D

Answer D

Marks 1

Unit II


Id 71

Question To be accessed from a member function of the derived class, data or functions in the base 

class must beA public

B private

C protected

D static

Answer C

Marks 1

Unit II


Id 72

Question If a base class contains a member function basefunc(), and a derived class does not 

contain a function with this name, can an object of the derived class access basefunc()?

A YES

B NO

C

D

Answer A

Marks 1

Unit II


Id 73

Question If no constructors are specified for a derived class, objects of the derived class will use the 

constructors in the base class.

A TRUE

B FALSE

C

D

Answer A

Marks 1

Unit II


Id 74

Question The scope-resolution operator usually

A specifies a particular class.

B tells what base class a class is derived from.

C resolves ambiguities.

D A and C

Answer D

Marks 1

Unit II


Id 75

Question Assume a class Derv that is privately derived from class Base. An object of class Derv 

located in main() can access

A public members of Derv.

B protected members of Derv.

C private members of Derv.D public members of Base.

Answer A

Marks 1

Unit II


Id 76

Question True or False: A class Dcan be derived from a class C, which is derived from a class B, 

which is derived from a class A.

A TRUE

B FALSE

C

D

Answer A

Marks 1

Unit II


Id 77

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

A TRUE

B FALSE

C

D

Answer B

Marks 1

Unit II


Id 78

Question A class hierarchy

A shows the same relationships as an organization chart.

B describes “has a” relationships.

C describes “is a kind of” relationships.

D shows the same relationships as a family tree.

Answer C

Marks 1

Unit II


Id 79

Question What is the output of the program?

#include <iostream>

#include <string>

using namespace std;

class Department {

public:

string dept;

Department(string d):dept(d) { }void getDeptName() { cout <<dept; }

};

class Student : private Department {

public:

string name;

Student(string n = "Not entered", string d = "ATDC") :

name(n), Department(d) { }

using Department::getDeptName;

};

int main() {

Student s("CSE");

s.getDeptName();

return 0;

}

A CSE

B ATDC

C Not entered

D Compilation Error

Answer B

Marks 2

Unit II


Id 80

Question Identify the lines on which the compiler will report an error.

#include <iostream>// ---1

using namespace std; // ---2

class Base { // ---3

int var_; // ---4

public: // ---5

Base():var_(0){} // ---6

}; // ---7

class Derived: public Base { public: // ---8

int varD_; // ---9

void print () { cout <<var_; } // ---10

}; // ---11

int main() { // ---12

Derived d; // ---13

d.var_ = 1; // ---14

d.varD_ = 1; // ---15

cout <<d.var_ <<""<<d.varD_; // ---16

return 0; // ---17

} // ---18

A 6, 10, 14, 15

B 6, 15

C 6, 14, 16D 10, 14, 16

Answer D

Marks 1

Unit II


Id 81

Question #include <iostream>

using namespace std;

class Base { public:

int var_;

void func(int){}

};

class Derived: public Base { public:

int varD_;

void func(int){}

};

int main() {

Derived d;

d.func(1);

return 0;

}

Which of the following function will be invoked by d.func(1)?

A Base::func(int)

B Derived::func(int)

C Compilation Error

D None of the above

Answer B

Marks 2

Unit II


Id 82

Question What is the output of the following program?

#include<iostream>

#include<string>

using namespace std;

class Base {

public:

void func_f1(int i) { cout <<"In base func_f1 "; }

void func_f2(int i) { cout <<"In base func_f2 "; }

};

class Derived: public Base {

public:

void func_f1(int i ) { cout <<"In derived func_f1 "; }

void func_f1(string s) { cout <<"func_f1 string "; }void func_f3(int i) { cout <<"In derived func_f3 "; }

};

int main() {

Base b;

Derived d;

d.func_f1(3);

d.func_f1("Blue");

d.func_f3(3);

d.func_f2(3);

return 0;

}

A Compilation Error: Cannot add new parameters to func_f1

B In derived func_f1 func_f1 string In derived func_f3 In base func_f2

C In base func_f2 func_f1 string In derived func_f3 In derived func_f1

D Compilation Error: Cannot define func_f3 containing same parameter type as func_f1

Answer B

Marks 2

Unit II


Id 83

Question What is the output of the following program? {Assume size of int as 4}

#include<iostream>

using namespace std;

class base {

int data;

};

class derived1: public base { };

class derived2: public derived1 { };

int main() {

cout <<sizeof(derived2);

return 0;

}

A 4

B 8

C 12

D 16

Answer A

Marks 1

Unit II


Id 84

Question What will be the output of the following program?

#include <iostream>using namespace std;

class B{ public: int base;

B() {}

~B() {}

};

class D: public B { public: int derived;

D() {}

~D() {}

};

int main() {

D d1;

B b1;

cout <<&b1.base <<"";

cout <<&d1.base;

return 0;

}

A 0x28fef8 0x28fef8

B 0x28fef8 0x28fefc

C Compilation Error

D None of the above

Answer B

Marks 2

Unit II


Id 85

Question What will be the output of the following program?

#include<iostream>

using namespace std;

class Base { public:

Base() { cout <<"Base Ctor"<<endl; }

~Base() { cout <<"Base Dtor"<<endl; }

};

class Derived: public Base { public:

Derived() { cout <<"Derived Ctor"<<endl; }

~Derived() { cout <<"Derived Dtor"<<endl; }

};

int main() {

Derived d1;

{

Base b1;

}

return 0;

}

A Base Ctor

Derived CtorBase Ctor

Base Dtor

Base Dtor

Derived Dtor

B Derived Ctor

Base Ctor

Base Ctor

Base Dtor

Derived Dtor

Base Dtor

C Derived Ctor

Base Ctor

Base Dtor

Derived Dtor

D Base Ctor

Derived Ctor

Base Ctor

Base Dtor

Derived Dtor

Base Dtor

Answer D

Marks 2

Unit II


Id 86

Question What will be the output of the program?

#include <iostream>

using namespace std;

class F1 {

public:

F1() { cout <<"F1 ctor "; }

~F1() { cout <<"F1 dtor "; }

};

class F2 : public F1 {

public:

F2() { cout <<"F2 ctor "; }

~F2() { cout <<"F2 dtor "; }

};

class F3 : public F1 {

const F2 &f2;

public:

F3() : f2(*new F2) { cout <<"F3 ctor "; }

~F3() { cout <<"F3 dtor "; }

};

int main() {F3 f3;

return 0;

}

A F1 ctor F2 ctor F3 ctor F3 dtor F2 dtor F1 dtor

B F1 ctor F1 ctor F2 ctor F3 ctor F3 dtor F1 dtor

C F1 ctor F3 ctor F3 dtor F1 dtor

D F1 ctor F1 ctor F2 ctor F3 ctor F3 dtor F2 dtor F1 dtor F1 dtor

Answer B

Marks 2

Unit II


Id 87

Question What will be the output of the program?

#include <iostream>

using namespace std;

class Room {

int number;

public:

Room(int num = 0): number(num) { }

void dimension() { cout <<number <<"Rooms "; }

};

class Building {

public:

Building() : ro(100) { }

void Build() { ro.dimension(); }

private:

Room ro;

};

int main() {

Building B;

B.Build();

return 0;

}

A 0 Rooms

B 100 Rooms

C Compilation Error: ro is private

D None of the above

Answer B

Marks 2

Unit II


Id 88

Question What will be the output of the program?

#include<iostream>using namespace std;

class Shape {

public:

int x, y;

Shape(int a = 0, int b = 0): x(a), y(b) {}

void draw()

{ cout <<x <<""<<y <<""; }

};

class Rectangle : public Shape {

public:

int w, h;

Rectangle(int a = 5, int b = 6): w(a), h(b), Shape(7, 8) {}

void draw()

{ Shape::draw(); cout <<w <<""<<h ; }

};

int main() {

Rectangle *r = new Rectangle(1,2);

r->draw();

return 0;

}

A 0 0 1 2

B 7 8 1 2

C 7 8 5 6

D 0 0 5 6

Answer B

Marks 2

Unit II


Id 89

Question You cannot change the precedence and associativity of an operator by overloading.

A TRUE

B FALSE

C

D

Answer A

Marks 1

Unit II


Id 90

Question When deriving a class from with protected inheritance, public members of the base class 

become___________ members of the derived class, and protected members of the

base class become _____________ members of the derived class.

A protected, protected.

B public, private

C private, private

D Private, protectedAnswer A

Marks 2

Unit II


Id 91

Question When deriving a class with public inheritance, public members of the base class become 

__________ members of the derived class, and protected members of the base class 

become ___________members of the derived class.

A private, private

B public, protected.

C protected, protected.

D private, protected

Answer B

Marks 2

Unit II


Id 92

Question C++ provides for ________________, which allows a derived class to inherit from many 

base classes, even if the base classes are unrelated.

A Multilevel inheritance

B Single level inheritance

C multiple inheritance

D Hierarchical inheritance 

Answer C

Marks 1

Unit II


Id 93

Question __________________is a form of software reuse in which new classes absorb the data 

and behaviors of existing classes and embellish these classes with new capabilities.

A Data hiding

B Inheritance

C Abstraction

D encapsulation 

Answer B

Marks 1

Unit II


Id 94

Question We can create the object of abstract class

A True

B False

C

D

Answer B

Marks 1Unit II


Id 95

Question All virtual functions in an abstract base class must be declared as pure virtual functions.

A TRUE

B FALSE

C

D

Answer B

Marks 1


Unit II

Id 96

Question A class is made abstract by declaring that class virtual.

A TRUE

B FALSE

C

D

Answer B

Marks 1

Unit II


Id 97

Question Polymorphic programming can eliminate the need for switch logic.

A TRUE

B FALSE

C

D

Answer A

Marks 1

Unit II


Id 98

Question Suppose a and b are integer variables and we form the sum a + b. Now suppose c and

D are floating-point variables and we form the sum c + d. The two +operators here are

clearly being used for different purposes. This is an example of ____________

A Operator Overloading

B Inheritance

C Function Overloading

D Constructor

Answer A

Marks 1

Unit II


Id 99

Question The operators that cannot be overloaded isA *

B -

C ::

D ()

Answer C

Marks 1

Unit II


Id 100

Question The operators that cannot be overloaded is

A *

B ?:

C >>

D <<

Answer B

Marks 1

Unit II



0 Comments