oop mcqs unit ii - web viewsuppose we are overloading a binary operator with friend function, how...

62
Id 1 Questio n 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 Questio n 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 Questio n 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 Questio n Selecting the appropriate overloaded function by the compiler is known as A late binding

Upload: buiminh

Post on 06-Feb-2018

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 1Question Polymorphism is supported by the c++ by using following waysA function overloadingB operator overloadingC virtual functionsD all of the aboveAnswer DMarks 1Unit II

Id 2Question Compile time polymorphism is supported byA function overloadingB virtual functionC operator overloadingD both a&cAnswer DMarks 1Unit II

Id 3Question Run time polymorphism is supported byA function overloadingB operator overloadingC virtual functionD both a and bAnswer CMarks 1Unit II

Id 4Question Selecting the appropriate overloaded function by the compiler is known asA late bindingB early bindingC both a and bD none of the aboveAnswer BMarks 1Unit II

Id 5Question object to function binding is done at compile time then is it known asA early bindingB compile time binding

Page 2: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

C none of the aboveD both a and bAnswer DMarks 1Unit II

Id 6Question Run time polymorphism is done by usingA function overloadingB operator overloadingC virtual functionD none of the aboveAnswer CMarks 1Unit II

Id 7Question Operator overloading is ---.A run time polymorphismB compile time polymorphismC none of the aboveD both a and bAnswer BMarks 1Unit II

Id 8Question Which of the following operator cannot be overloadedA scope resolution operator(::)B Size of operator (sizeof[])C Conditional operator(?:)D All of the aboveAnswer DMarks 1Unit II

Id 9Question Which of the operator cannot be overloadedA >=B &C <=D ::Answer DMarks 1Unit II

Page 3: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 10Question While performing operator overloading which function/keyword we have to useA FunctionB OperatorC OpD none of the aboveAnswer BMarks 1Unit II

Id 11Question Which of the statement is not true about operator overloadingA we can overload only existing operatorB basic meaning cannot be changedC binary operator should have return typeD All of the aboveAnswer DMarks 1Unit II

Id 12Question Pick up the correct statement related with operator overloadingA we can overload a class access operatorB we can change the meaning of basic operatorC binary operator should have a return typeD both a and bAnswer CMarks 1Unit II

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

to passA 1B 2C 0D none of the aboveAnswer CMarks 1Unit II

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

of argument we have to passA 1B 2

Page 4: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

C 3D none of ths aboveAnswer BMarks 1Unit II

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

have to passA 1B 2C 0D none of the abveAnswer AMarks 1Unit II

Id 16Question What is polymorphismA it is ability to take many formsB it is instance of classC one class acquire the properties of another classD All of the aboveAnswer AMarks 1Unit II

Id 17Question What is true about the operator overloadingA with friend function we need to pass two arguments for binary operatorB with friend function we need to pass one arguments for unary operatorC both a and bD none of the aboveAnswer CMarks 1Unit II

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

associated with it.A function overloadingB virtual functionC operator overloadingD none of the aboveAnswer CMarks 1

Page 5: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Unit II

Id 19Question Converting from small to larger data type is known as ____.A promotionB operatorC polymorphismD none of the aboveAnswer AMarks 1Unit II

Id 20Question what are the types of type conversionA implicitB explicitC both a and bD none of the aboveAnswer CMarks 1Unit II

Id 21Question Reusability is supported by following featureA polymorphismsB message passingC inheritanceD operator overloadingAnswer CMarks 1Unit II

Id 22Question Deriving a new class from a base class is known as __.A polymorphismsB inheritanceC message passingD operator overloadingAnswer BMarks 1Unit II

Id 23Question Base class is also known as___.A super classB parent class

Page 6: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

C both a and bD none of the aboveAnswer CMarks 1Unit II

Id 24Question Child class is also known asA sub classB derived classC both a and bD known classAnswer CMarks 1Unit II

Id 25Question Derived class___ cannot access from base classA constructorB destructorsC copy constructorD all of the aboveAnswer DMarks 1Unit II

Id 26Question we can derive a new class from a derived classA trueB falseCDAnswer AMarks 1Unit II

Id 27Question How many parameter does a conversion operator take?A 0B 2C 3D as many as possibleAnswer AMarks 1Unit II

Page 7: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 28Question __is used to define pure virtual function?A &B =0C @D *Answer BMarks 1Unit II

Id 29Question Which is also known as abstract class?A virtual functionB pure virtual functionC derived class functionD base class functionAnswer BMarks 1Unit II

Id 30Question pick the correct optionA We can make the instance of the abstract classB We can not make the instance of the abstract classC both a and bD none of the aboveAnswer BMarks 1Unit II

Id 31Question How many access specifiers are there in c++?A 2B 3C 5D 4Answer BMarks 1Unit II

Id 32Question Where we have to use an abstract class?A in base class onlyB in derived class onlyC both and bD None of the above

Page 8: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Answer AMarks 1Unit II

Id 33Question For what we can apply accessA functionB data memberC none of the above specifierD both a and cAnswer DMarks 1Unit II

Id 34Question What is default access specifier for class?A publicB protectedC privateD none of the aboveAnswer CMarks 1Unit II

Id 35Question We have to define a constructor for the derived class must be required____.A if base class constructor does not require argumentsB if base/parent class constructor required argumentsC no needD alwaysAnswer BMarks 1Unit II

Id 36Question Use of the friend function is___.A the class allowing access to another classB the private section of a classC the public section of the classD all of the aboveAnswer DMarks 1Unit II

Id 37Question If an attribute is private define then which method can have access to it

Page 9: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

A only static functionB only functions of that classC only method in that packageD none of the aboveAnswer BMarks 1Unit II

Id 38Question What is syntax of deriving a new class from base class is___.A class name, new class nameB new class name, base class nameC class name: access specifier class nameD none of the aboveAnswer CMarks 1Unit II

Id 39Question Which constructor will initialize the base class data memberA base classB derived classC derived derived classD none of theseAnswer AMarks 1Unit II

Id 40Question Inheritance can be done using :: symbolA TrueB FalseCDAnswer BMarks 1Unit II

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

as____.A multiple inheritanceB single inheritanceC hybrid inheritance

Page 10: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

D multilevel inheritanceAnswer AMarks 1Unit II

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

known as ______.A multiple inheritanceB single inheritanceC hybrid inheritanceD multilevel inheritanceAnswer DMarks 1Unit II

Id 43Question The base class will provide you__________.A specific objects than the derived classB more generalized version of derived classC empty template of base classD all of the aboveAnswer BMarks 1Unit II

Id 44Question Pick up the correct statement form following

i)we have to use abstract keyword to define the abstract classii)inheritance allows multilevel class hierarchies more than two levels alsoiii)reusability is supported by derivationiv) we can change the meaning of operator during operator overloading

A i onlyB ii onlyC i and ii onlyD ii and iii onlyAnswer DMarks 2Unit II

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

i)constructorii)destructoriii)operator=()iv)friends

Page 11: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

A i and iiB ii and iiiC only i, iii and ivD all of the aboveAnswer DMarks 1Unit II

Id 46Question Choose the correct the statement from following

i)inheritance supported in terms of single, multiple , multilevel ,hybrid inheritanceii) polymorphisms is supported by function overloading , operator overloading and virtual functioniii) abstraction is not supported by c++

A i is correctB only ii is correctC i and ii is correctD none of the aboveAnswer CMarks 1Unit II

Id 47Question _____types of classes in c++.A 1B 2C 3D 4Answer CMarks 1Unit II

Id 48Question :_______is used to define a pure virtual function.A $B ^C =0D #Answer CMarks 1Unit II

Id 49Question Pick up the correct statementA a base class may have more than one classB derived class can be derived from more than one class

Page 12: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

C both a and bD none of the aboveAnswer CMarks 1Unit II

Id 50Question class A: public B, public C is a type of inheritanceA SingleB MultipleC MultilevelD HybridAnswer BMarks 1Unit II

Id 51Question When we have to use the mutable keywordA data member to change within a const member functionB not allow the data member to change within a const member functionC it will copy the values of the variableD none of the above mentionedAnswer AMarks 1Unit II

Id 52Question choose the correct statementA destructor cannot be inheritedB private member not inherited to derived classC constructor cannot inheritedD a and cAnswer DMarks 1Unit II

Id 53Question Use of function or operator to act different ways on different data type is called asA derivationB inheritanceC polymorphismsD none of the aboveAnswer CMarks 1Unit II

Page 13: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 54Question Choose the correct statementA Constructor has a return typeB constructor always define in public scopeC constructor has same name that of class nameD b and cAnswer DMarks 1Unit II

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

takes_________.A one argumentB two argumentC no argumentD none of the aboveAnswer CMarks 1Unit II

Id 56Question Pick up the correct statement

i)abstract type of class should contain at least one virtual functionii)we can create an object of abstract classiii)abstract class is used to provide an interface to subclassesiv)abstract class can also have normal function

A i and ii onlyB i , ii, and iii onlyC i ,iii and ivD all of the aboveAnswer DMarks 1Unit II

Id 57Question What is function overloadingA we have to use same function name but different parameterB different function name but same parameterC both a and bD none of the aboveAnswer AMarks 1Unit II

Id 58

Page 14: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Question Virtual base class is used to ____.A to perform operator overloadingB to perform function overloadingC to remove ambiguity in multiple inheritanceD all of the aboveAnswer CMarks 1Unit II

Id 59Question Pick up the correct statementA protected member from base class can be accessed by own class and its all subclassesB protected member are not inherited by any other classC Protected member are combination of public and private access memberD all of the aboveAnswer DMarks 1Unit II

Id 60Question pick up the correct statementA base class and derived class can have their own constructorB base class and derived class can have their own destructorC neither a or neither bD both a and bAnswer DMarks 1Unit II

Id 61Question Make a correct sequence of a statement

i)destructor of derived class is calledii)destructor of base class is callediii)constructor of derived class is callediv)constructor of base class is called

A i,ii,iv,iiiB iv,iii,ii,iC iv,iii,i,iiD i,ii,iii,ivAnswer CMarks 1Unit II

Id 62Question Operator overloading isA making C++ operators work with objects.

Page 15: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

B giving C++ operators more than they can handle.C giving new meanings to existing C++ operators.D Both A and CAnswer DMarks 2Unit II

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

to work correctly, the overloaded - operator mustA take two arguments.B return a value.C use the object of which it is a member as an operand.D Both B and CAnswer DMarks IIUnit 2

Id 64Question When you overload an arithmetic assignment operator, the resultA 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 CAnswer DMarks 2Unit II

Id 65Question To convert from a user-defined class to a basic type, you would most likely useA 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 DMarks 1Unit II

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

of operands.A TRUEB FALSECDAnswer A

Page 16: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Marks 1Unit II

Id 67Question The compiler won’t object if you overload the * operator to perform division.A TRUEB FALSECDAnswer AMarks 1Unit II

Id 68Question Inheritance is a way toA 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 CAnswer DMarks 1Unit II

Id 69Question Advantages of inheritance includeA providing a useful conceptual framework.B facilitating class libraries.C avoiding the rewriting of code.D All of the aboveAnswer DMarks 2Unit II

Id 70Question Adding a derived class to a base class requires fundamental changes to the base class.A TRUEB FALSECDAnswer DMarks 1Unit II

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

class must be

Page 17: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

A publicB privateC protectedD staticAnswer CMarks 1Unit II

Id 72Question 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 YESB NOCDAnswer AMarks 1Unit II

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

constructors in the base class.A TRUEB FALSECDAnswer AMarks 1Unit II

Id 74Question The scope-resolution operator usuallyA specifies a particular class.B tells what base class a class is derived from.C resolves ambiguities.D A and CAnswer DMarks 1Unit II

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

located in main() can accessA public members of Derv.B protected members of Derv.C private members of Derv.

Page 18: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

D public members of Base.Answer AMarks 1Unit II

Id 76Question 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 TRUEB FALSECDAnswer AMarks 1Unit II

Id 77Question It is illegal to make objects of one class members of another class.A TRUEB FALSECDAnswer BMarks 1Unit II

Id 78Question A class hierarchyA 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 CMarks 1Unit II

Id 79Question What is the output of the program?

#include <iostream>#include <string>using namespace std;class Department {public:string dept;Department(string d):dept(d) { }

Page 19: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

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 CSEB ATDCC Not enteredD Compilation ErrorAnswer BMarks 2Unit II

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

#include <iostream>// ---1using namespace std; // ---2class Base { // ---3int var_; // ---4public: // ---5Base():var_(0){} // ---6}; // ---7class Derived: public Base { public: // ---8int varD_; // ---9void print () { cout <<var_; } // ---10}; // ---11int main() { // ---12Derived d; // ---13d.var_ = 1; // ---14d.varD_ = 1; // ---15cout <<d.var_ <<""<<d.varD_; // ---16return 0; // ---17} // ---18

A 6, 10, 14, 15B 6, 15C 6, 14, 16

Page 20: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

D 10, 14, 16Answer DMarks 1Unit II

Id 81Question #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 ErrorD None of the aboveAnswer BMarks 2Unit II

Id 82Question 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 "; }

Page 21: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

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_f1B In derived func_f1 func_f1 string In derived func_f3 In base func_f2C In base func_f2 func_f1 string In derived func_f3 In derived func_f1D Compilation Error: Cannot define func_f3 containing same parameter type as func_f1Answer BMarks 2Unit II

Id 83Question 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 4B 8C 12D 16Answer AMarks 1Unit II

Id 84Question What will be the output of the following program?

#include <iostream>

Page 22: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

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 0x28fef8B 0x28fef8 0x28fefcC Compilation ErrorD None of the aboveAnswer BMarks 2Unit II

Id 85Question 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 CtorDerived Ctor

Page 23: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Base CtorBase DtorBase DtorDerived Dtor

B Derived CtorBase CtorBase CtorBase DtorDerived DtorBase Dtor

C Derived CtorBase CtorBase DtorDerived Dtor

D Base CtorDerived CtorBase CtorBase DtorDerived DtorBase Dtor

Answer DMarks 2Unit II

Id 86Question 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() {

Page 24: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

F3 f3;return 0;}

A F1 ctor F2 ctor F3 ctor F3 dtor F2 dtor F1 dtorB F1 ctor F1 ctor F2 ctor F3 ctor F3 dtor F1 dtorC F1 ctor F3 ctor F3 dtor F1 dtorD F1 ctor F1 ctor F2 ctor F3 ctor F3 dtor F2 dtor F1 dtor F1 dtorAnswer BMarks 2Unit II

Id 87Question 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 RoomsB 100 RoomsC Compilation Error: ro is privateD None of the aboveAnswer BMarks 2Unit II

Id 88Question What will be the output of the program?

#include<iostream>

Page 25: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

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 2B 7 8 1 2C 7 8 5 6D 0 0 5 6Answer BMarks 2Unit II

Id 89Question You cannot change the precedence and associativity of an operator by overloading.A TRUEB FALSECDAnswer AMarks 1Unit II

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

become___________ members of the derived class, and protected members of thebase class become _____________ members of the derived class.

A protected, protected.B public, privateC private, privateD Private, protected

Page 26: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Answer AMarks 2Unit II

Id 91Question 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, privateB public, protected.C protected, protected.D private, protectedAnswer BMarks 2Unit II

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

base classes, even if the base classes are unrelated.A Multilevel inheritanceB Single level inheritanceC multiple inheritanceD Hierarchical inheritance Answer CMarks 1Unit II

Id 93Question __________________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 hidingB InheritanceC AbstractionD encapsulation Answer BMarks 1Unit II

Id 94Question We can create the object of abstract classA TrueB FalseCDAnswer BMarks 1

Page 27: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Unit II

Id 95Question All virtual functions in an abstract base class must be declared as pure virtual functions.A TRUEB FALSECDAnswer BMarks 1Unit II

Id 96Question A class is made abstract by declaring that class virtual.A TRUEB FALSECDAnswer BMarks 1Unit II

Id 97Question Polymorphic programming can eliminate the need for switch logic.A TRUEB FALSECDAnswer AMarks 1Unit II

Id 98Question 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 areclearly being used for different purposes. This is an example of ____________

A Operator OverloadingB InheritanceC Function OverloadingD ConstructorAnswer AMarks 1Unit II

Id 99Question The operators that cannot be overloaded is

Page 28: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

A *B -C ::D ()Answer CMarks 1Unit II

Id 100Question The operators that cannot be overloaded isA *B ?:C >>D <<Answer BMarks 1Unit II

Id 101Question Which of the following operator(s) can not be overloadedA .*B ::C ?:D All of the aboveAnswer DMarks 1Unit II

Id 102Question Which of the following is true about this pointer?A It is passed as a hidden argument to all function callsB It is passed as a hidden argument to all non-static function callsC It is passed as a hidden argument to all static functionsD None of the aboveAnswer BMarks 1Unit II

Id 103Question Predict the output of following C++ program.

#include<iostream>using namespace std; class Test{

Page 29: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

private: int x;public: Test(int x = 0) { this->x = x; } void change(Test *t) { this = t; } void print() { cout <<"x = "<<x <<endl; }}; int main(){ Test obj(5); Test *ptr = new Test (10); obj.change(ptr); obj.print(); return 0;}

A x = 5B x = 10C Compiler ErrorD Runtime ErrorAnswer CMarks 2Unit II

Id 104Question Which of the followings is/are automatically added to every class, if we do not write our

own.A Copy ConstructorB Assignment OperatorC A constructor without any parameterD All of the aboveAnswer DMarks 2Unit II

Id 105Question What is the output of following program?

#include<iostream>using namespace std;class Point { Point() { cout <<"Constructor called"; }}; int main(){ Point t1;

Page 30: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

return 0;}

A Compiler ErrorB Runtime ErrorC Constructor calledD Segmentation FaultAnswer AMarks 1Unit II

Id 106Question What will be the output of following program?

#include <iostream>using namespace std; class Test{public: Test() { cout <<"Hello from Test() "; }} a; int main(){ cout <<"Main Started "; return 0;}

A Main StartedB Main Started Hello from Test()C Hello from Test() Main StartedD Compiler Error: Global objects are not allowedAnswer CMarks 2Unit II

Id 107Question Which of the following operators are overloaded by default by the compiler?

1) Comparison Operator ( == )2) Assignment Operator ( = )

A Both 1 and 2B Only 1C Only 2D None of the twoAnswer CMarks 1Unit II

Page 31: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 108Question A normal C++ operator that acts in a special way on newly defined data types is called

_______A EncapsulatedB OverloadedC ClassifiedD InheritedAnswer BMarks 1Unit II

Id 109Question The correct function name for overloading the addition + operator is __A Operator _+B Operator :+C Operator (+)D Operator +Answer DMarks 1Unit II

Id 110Question Which of the following operators cannot be overloaded?A → operatorB . operatorC [ ] operatorD &operatorAnswer BMarks 1Unit II

Id 111Question Which of the following operators cannot be overloaded?A +B -C [ ]D ::Answer DMarks 1Unit II

Id 112Question Pick the incorrect statement from the followingA The overloaded operators follow the syntax rules of original operator.B Only existing operators can be overloaded

Page 32: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

C Overloaded operator must have at least one operand of its class typeD Overloaded operators can change the meaning of the original operatorAnswer DMarks 1Unit II

Id 113Question For operators to be overloaded as non static member functions:A Both binary and unary operators take one argument.B Binary operators can have one argument and unary operators can not have anyC Neither binary nor unary operators can have argumentsD Binary operators can have two arguments and unary operators can have oneAnswer BMarks 1Unit II

Id 114Question Which of the following is an operator function?A Member overloadingB Function overloadingC Operator overloadingD None of theseAnswer CMarks 1Unit II

Id 115Question Operator overloading means _______A Giving new meaning to existing operator without changing its original

MeaningB Making C++ operators to work with objectsC Making new types of operatorD Both a and bAnswer DMarks 1Unit II

Id 116Question For overloading =+ implicitly _______A + and = operators need to be overloaded implicitlyB Only + operator need to be overloaded implicitlyC Only = operator need to be overloaded implicitlyD The += operator cannot be overloaded implicitlyAnswer DMarks 1Unit II

Page 33: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 117Question Overloading a postfix increment operator by means of a member function takes-------A No argumentB One argumentC Two argumentsD Three ArgumentsAnswer AMarks 1Unit II

Id 118Question If you overload only prefix operator ++ then the postfix ++ operator is ______A Does not workB Works arbitrarilyC Works naturallyD Works as if prefix ++ operatorAnswer DMarks 1Unit II

Id 119Question When compiler decides binding of an overloaded member then it is called________A Static bindingB Dynamic bindingC Local bindingD None of theseAnswer AMarks 1Unit II

Id 120Question One can redefine the working of _______ to work with objects.A Preprocessor directivesB White space charactersC Standard operatorsD None of theseAnswer CMarks 1Unit II

Id 121Question Choose the correct option:

I. When you overload <<operator the >>operator automatically getsoverloadedII. You can overload unary operator to work with binary operator

Page 34: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

A Only I is trueB Only II is trueC Both I and II are trueD Neither I nor II are trueAnswer DMarks 1Unit II

Id 122Question Choose the correct option

I.If you do not want to make use of operator overloading, you can achieve that effect using user defined functionII. The sizeof operator can be overloaded

A Only I is trueB Only II is trueC Both I and II are trueD Neither I nor II are trueAnswer AMarks 1Unit II

Id 123Question The array subscript operator [] when overloaded cannot ______A Take user defined objects are operandsB Take float as an operandC Take multiple values inside (for example: [5,7] )D None of theseAnswer CMarks 1Unit II

Id 124Question The prototype of overloaded cast operator functions do not _______A specify the type they convert toB specify the return type

C need to be defined inside the class whose objects are being converted

D none of these

Answer BMarks 1Unit II

Id 125

Page 35: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Question Which of the following operators cannot be overloaded ?A +=B <<C ?:D FUNCTION CALL()Answer CMarks 1Unit II

Id 126Question Which of the following operators cannot be overloaded ?A ::B SizeofC Conditional operator ?:D All of theseAnswer DMarks 1Unit II

Id 127Question The overloading the function operator________.A requires class with overloaded operatorsB makes use of parameterized constructorC allows to create objects that are syntactically like functionsD none of theseAnswer AMarks 1Unit II

Id 128Question Choose the incorrect statement from the following.A Constructors can be overloaded.B Only existing operators must be overloadedC the overloaded operators must follow the syntax rules of the original operatorD The overloaded operators must have atleast one operand of its class typeAnswer BMarks 1Unit II

Id 129Question Overloading without explicit arguments to an operator function is called______.A unary operatorB binary operatorC nested classD none of theseAnswer A

Page 36: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Marks 1Unit II

Id 130Question In binary overloaded function which are overloaded through friend function take_______A three explicit argumentsB two explicit argumentsC one explicit argumentD no argumentAnswer BMarks 1Unit II

Id 131Question In binary overloaded function which are overloaded through member function

take__________A three explicit argumentsB two explicit argumentsC one explicit argumentD no argumentAnswer CMarks 1Unit II

Id 132Question The unary operators are overloaded by member function then it takes ______A three explicit argumentsB two explicit argumentsC one explicit argumentD no argumentAnswer DMarks 1Unit II

Id 133Question Choose the correct choice.

I. All the operators in C++ can be overloaded.II. We can change the basic meaning of operator while overloading it.

A Only I is trueB Only II is trueC Both I and II are trueD Neither I nor II are trueAnswer DMarks 1Unit 2

Page 37: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 134Question Which of the following operator can be overloaded through friend function ?A ::B +C =D ->Answer BMarks 1Unit II

Id 135Question The name of the operator function that overloads the / symbol is________.A operator /()B /op()C / operator()D op/()Answer AMarks 1Unit II

Id 136Question In binary operator overloaded operator function the second operand should be______.

A passed by valueB ImplicitC passed by referenceD none of theseAnswer CMarks 1Unit II

Id 137Question Function overloading is run time polymorphismsA TrueB FalseCDAnswer BMarks 1Unit II

Id 138Question Following overloaded operator cannot be inherited by derived class_______.A >B =

Page 38: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

C *D /Answer BMarks 1Unit II

Id 139Question Choose the correct choice.A The conditional operator can be overloadedB While overloading using the friend function the binary operator requires one argumentC Operator precedence cannot be changedD None of theseAnswer CMarks 1Unit II

Id 140Question Which of the following operator can be overloaded through friend function ?A ()B []C ->D *Answer DMarks 1Unit II

Id 141Question When we overload we want to______.A compare and copy objectB assign one object to anotherC compare two objectsD test for equalityAnswer BMarks 1Unit II

Id 142Question Operator overloading is also called one form of polymorphism because_______.A the overloaded operators have many formsB the overloaded operators can be declared virtualC the overloaded function can perform various tasks depending upon the type of objectD None of theseAnswer CMarks 1Unit II

Page 39: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 143Question Overloading meansA two or more methods in the same class that have same nameB calling the method which has actual parametersC two or more methods having same name but present in different classD none of theseAnswer CMarks 1Unit II

Id 144Question The inheritance mechanism provides meaning of deriving______A new operator from exciting oneB new function from exciting oneC new class from exciting oneD all of theseAnswer CMarks 1Unit II

Id 145Question A class derived from the exciting class is known as______A new classB InheriteeC derived classD none of theseAnswer CMarks 1Unit II

Id 146Question The derived class is derived from__________A derived classB base classC both a&bD none of theseAnswer BMarks 1Unit 2

Id 147Question Which of the following can be derived from base class in inheritace ?A data membersB member functionC both a&bD none of these

Page 40: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Answer CMarks 1Unit II

Id 148Question The inheritance is described as a _____ relationshipA has aB is aC associationD none of theseAnswer BMarks 1Unit II

Id 149Question Which of the following allows you to create derived class that inherits properties from

more than one base class ?A multilevel inheritanceB multiple inheritanceC single inheritanceD Hybrid inheritanceAnswer BMarks 1Unit II

Id 150Question The principle by which the knowledge of general category can be applied to more

specific objects is called _____A polymorphismB overridingC inheritanceD none of theseAnswer AMarks 1Unit II

Id 151Question Parent:child is________A base:derivedB derived:drivenC child:superD subclass:superclassAnswer AMarks 1Unit II

Page 41: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 152Question What is the syntax of inheritance of a class ?A Class class _nameB Class name:access specifierC Class name:access specifier class nameD none of theseAnswer CMarks 1Unit II

Id 153Question If an attribute is private then which methods have access to it?A Only static methods in the same classB Only the methods defined in that classC Only the methods of the same packageD none of theseAnswer BMarks 1Unit II

Id 154Question Which of the following advantage cannot be achieved by using multiple inheritance?A polymorphismB dynamic bindingC both a&bD none of theseAnswer CMarks 1Unit II

Id 155Question Which of the symbol used to create multiple inheritance ?A DotB CommaC Hash #D DollarAnswer BMarks 1Unit II

Id 156Question Using multiple inheritanceA there can be virtual classB it can not be include virtual classC the base classes must have only default constructorD none of these

Page 42: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Answer AMarks 1Unit II

Id 157Question The______member function is declared in base class but redefined in derived classA classB overloadedC operatorD virtualAnswer DMarks 1Unit II

Id 158Question In public inheritance ______A All the members of base class are inherited and are made publicB Members of base class that are not private are inherited and retain their access typeC All the members of base class are inherited and retain their access typeD Only public members of base class are inherited and they remain publicAnswer CMarks 1Unit II

Id 159Question If class C is derived class of class B and class B is a derived class of A. If we instantiate

class B object then the first constructor called belongs to classA AB BC can be A or BD one cannot achieve such inheritanceAnswer AMarks 1Unit II

Id 160Question When the object of derived class expire, first the _______ is invoked followed by the

________.A derived class constructor, base class destructorB derived class destructor , base class destructorC base class destructor , derived class destructorD none of theseAnswer BMarks 1Unit II

Page 43: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 161Question If class A inherits from class B then B is called ________ ans A is called ________ of B.A superclass and subclassB subclass and superclassC subclass and child classD superclass and parent classAnswer AMarks 1Unit II

Id 162Question What does derived class does not inherit from the base class _______.A constructor and destructorB operator=() membersC friendsD all of theseAnswer DMarks 1Unit II

Id 163Question Which constructor will initialise the base class data member ?A Base classB Derived classC Derived derived classD None of theseAnswer AMarks 1Unit II

Id 164Question If class A is a friend class of class B, if class B is friend class of class C then_______A class C is friend class ofB class A is friend class ofC class A and class C do not have any friendship relation.D none of theseAnswer CMarks 1Unit II

Id 165Question _________ class is tightly coupled with other class.A friendB virtualC abstractD none of these

Page 44: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Answer AMarks 1Unit II

Id 166Question The keyword friend is used in ___________.A the class allowing access to another classB the private section of a classC the public section of a classD all of theseAnswer DMarks 1Unit II

Id 167Question Class Test:public A, public B is an example of multiple inheritance.A FalseB TrueCDAnswer BMarks 1Unit II

Id 168Question Which of the following interface determines how your program will be used by other

program?A PublicB PrivateC ProtectedD None of theseAnswer AMarks 1Unit II

Id 169Question When base class pointer points to derived class object___________A it can access only base class membersB it can access only derived class membersC both base class &derived class membersD None of theseAnswer AMarks 1Unit II

Id 170

Page 45: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Question The base class will offer_____A more specific object than the derived classB more generalized version of its derived classC empty templates of its derived classD none of theseAnswer BMarks 1Unit II

Id 171Question In my program I have overloaded TEST::operator+ and TEST::operator= What is the

effect on TEST::operator+= ?A The TEST::operator+= will be automatically overloaded .first TEST::operator+ will get

overloaded and then TEST::operator=B The TEST::operator+= will be automatically overloaded .first TEST::operator= will

get overloaded and then TEST::operator+C TEST::operator+= will made invalidD There will be no effect because all three are independentAnswer DMarks 1Unit II

Id 172Question What will happen on execution of the following code ?

Class base{};class derived: protected base{};

A It will not compile as the class body of the base class is not definedB It will not compile as the class body of the derived class is not definedC It will compile successfullyD The compilation of above code is dependent upon the type of data provided to itAnswer CMarks 1Unit II

Id 173Question The base class will offer_____A more specific object than the derived classB more generalized version of its derived classC empty templates of its derived classD none of theseAnswer BMarks 1Unit II

Page 46: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

Id 174Question The hybrid inheritance is _____A multiple inheritanceB multilevel inheritanceC multipath inheritanceD both a &cAnswer DMarks 1Unit II

Id 175Question Ho

w many types of inheritance are thereA 1B 2C 4D 5Answer DMarks 1Unit II

Id 176Question Choose the correct optionA a) a constructor can not be called explicitlyB b) a destructor is not inheritedC c) constructor can not be inheritedD d) All of theseAnswer DMarks 1Unit II

Id 177Question Suppose class derived is derived from a class Base. Both the classes contain the

Function name display() that take no argument. What will be the statement in the class derived which will called the display function of base class

A Display()B Base:display()C Base ::display()D Can make such a cellAnswer CMarks 1Unit II

Id 178Question Suppose class derived is derived from a class Base privately. The object of class Derived

Page 47: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

is located in main() can access_______.A public members of baseB private member of baseC protected members of baseD public members of derivedAnswer DMarks 1Unit II

Id 179Question Multiple inheritance causes for a derived class to have ___members.A ambiguousB publicC privateD protectedAnswer AMarks 1Unit II

Id 180Question What will be the first line of specifier for the class tier, wheel &rubber. Make use of

public rubberA Class Tier:public wheel, public rubberB Class wheel:public tier, public rubberC Class rubber:public tier, public wheelD none of theseAnswer AMarks 1Unit II

Id 181Question Which is the correct class defination for class C ,Which inherits from A &B classesA Class C:A,BB Class C::A,BC Class C:public A,public BD Class C:: public A,Public BAnswer CMarks 1Unit II

Id 182Question The ability of function or operator to act in different ways on different data type is

called___________A inheritanceB polymorphismC encapsulation

Page 48: OOP MCQs Unit II -    Web viewSuppose we are overloading a binary operator with friend function, how many parameter of argument we have to pass

D none of theseAnswer BMarks 1Unit II

Id 183Question _____class that declares or inherits a virtual function.A Encapsulation dataB Inherited classC Polymorphic classD none of theseAnswer CMarks 1Unit II

Id 184Question Choose the correct option.A A base class may have more then one derived classB Derived class may have more than one derived classC Both a &bD Neither a nor bAnswer CMarks 1Unit II

Id 185Question reusability is provided by which feature of c++A polymorphismsB abstractionC derivationD none of the aboveAnswer CMarks 1Unit II

Id 186Question What types of derivations are supported by c++?A singleB multipleC multilevelD all of the aboveAnswer DMarks 1Unit II