unit-2 syllabus for unit-2 reference book. · unit-2 syllabus for unit-2 introduction, need of...

45
OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P. UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, overloading using friends, rules for operator overloading, type conversions Concept and need, single inheritance, base and derived classes, friend classes, types of inheritance, hybrid inheritance, member access control, static class, multiple inheritance, ambiguity, virtual base class,polymorphism, virtual functions, pure virtual functions, abstract base class, virtual destructor, early and late binding, container classes Reference Book. A. Michael Berman, “Data structures via C++”, Oxford University Press, 2002, ISBN-0-19- 510843-4. Suggested Book for unit-2 Object-oriented programming in C++ By Robert Lafore , Galgotia Publication Practical Assignment Based on Unit-2 1. Compulsory assignment no 1 to 9 Id Keep it blank Question Which operator is having right to left associativity in the following ? A Array subscripting B Function call C Addition and subtraction D Type cast Answer Correct Option D Marks 2 Unit 2 Id Keep it blank Question Which operator is having the highest precedence? A Postfix B Unary C shift D Equality Answer Correct Option A Marks 2 Unit 2 Id Keep it blank Question Operator ?: is known as __________ A Conditional B Relational C Casting operator D None of the above Answer Correct Option A Marks 2 Unit 2 Id Keep it blank DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .1

Upload: others

Post on 25-Feb-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

UNIT-2

Syllabus for Unit-2Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, overloading using friends, rules for operator overloading, type conversions Concept and need, single inheritance, base and derived classes, friend classes, types of inheritance, hybrid inheritance, member access control, static class, multiple inheritance, ambiguity, virtual base class,polymorphism, virtual functions, pure virtual functions, abstract base class, virtual destructor, early and late binding, container classesReference Book.

● A. Michael Berman, “Data structures via C++”, Oxford University Press, 2002, ISBN-0-19-510843-4.

Suggested Book for unit-2● Object-oriented programming in C++ By Robert Lafore , Galgotia Publication

Practical Assignment Based on Unit-21. Compulsory assignment no 1 to 9

Id Keep it blankQuestion Which operator is having right to left associativity in the following ? A Array subscriptingB Function callC Addition and subtraction D Type castAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which operator is having the highest precedence?A PostfixB UnaryC shift D EqualityAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion Operator ?: is known as __________

A ConditionalB RelationalC Casting operatorD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blank

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .1

Page 2: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Question What is the output of this program ?#include <iostream>using namespace std;int main(){int a;a=5+3*5;cout << a;return 0;}

A 35 B 20C 25D 30Answer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion What is the use of dynamic_cast operator ?A It converts virtual base class to derived classB It converts virtual base object to a derived objectC It will convert the operator based on precedenceD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using narnespace std;int main ( ){int a = 5, b = 6, c,d;c = a,b;d = (a. b);cout << c << , t , << d:return 0;}

A 5 6B 6 5C 6 7 D None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the output ofthis program ?

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .2

Page 3: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

#include <iostream>using namespace std;int main ( ){int i, j;j =10;i= (j++,j+ 100,999 +j);cout<<i;return 0;}

A 1000B 11C 1010D 1001Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;main( ){double a = 21.09399 ;float b = 10.20;int c ,d ;c = (int) a;d = (int) b;cout << c <<'t'<< d;return 0;}

A 20 10 B 10 21 C 21 10D None of the above Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion How many sequences of statements are present in c++?A 4B 3C 5D 6Answer Correct Option CMarks 2Unit 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .3

Page 4: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep it blankQuestion The if..else statement can be replaced by which operator ?A Bitwise operatorB Conditional operatorC Multiplicative operatorD None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion The switch statement is also called as ?A Choosing structureB Selective structureC Certain structureD None of the above Answer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion The destination statement for the goto label is identified by what label ?A $B @C *D :Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;int main ( ){int n;for(n=5;n>0;n-){cout << n;if (n = = 3)break;}return 0;}

A 543B 54C 5432

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .4

Page 5: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

D 53Answer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;int main (){int a = 10;if (a < 15){time;cout << a;goto time;}break;return 0;}

A 1010B 10C Infinitely print 10D Compile time errorAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;int main (){int n = l5;for(; ;)cout << n;return 0;}

A ErrorB 15C Infinite times of printing nD None of the aboveAnswer Correct Option CMarks 2Unit 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .5

Page 6: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;int main(){int i;for (i = 0; i < 10; i++);{cout << i;}return 0;}

A 0123456789B 10C 012345678910D Compile time errorAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion How many types of loops are there ?A 4B 2C 3D 1Answer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion Which looping Process is best used when the number of iterations is known? A ForB whileC Do-whileD All looping processes require that the iterations be knownAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion How many types of comments are there in C++ ?A 1B 2C 3D 4Answer Correct Option BMarks 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .6

Page 7: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Unit 2

Id Keep it blankQuestion What is a comment in c++ ?A Comments are parts of the source code disregarded by the compilerB Comments are executed by compiler to find the meaning of the commentC Comments are executableD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What type of comments does c++ support ?A Single lineB Multi lineC Single line and multi lineD None of the aboveAnswer Correct Option CMarks 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;int main (){/+ this is comment*cout << "hello world”;return 0;}

A Hello worldB helloC Compile time errorD None of the aboveAnswer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion What is used to write multi line comment in c++ ?A *B \C Both A and B D None of the aboveAnswer Correct Option AMarks 2Unit 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .7

Page 8: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep it blankQuestion What will happen when we use void in argument passing ?A It will not return value to its callerB It will return value to its callerC Both (a) and (b) are correctD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespaces std;void Sum(int a, int b, int & c){a=b+c;b=a+c;c=a+b;}int main(){int x=2 , y=3;Sum(x, y, y);cout << x .< “ ” <. y;return 0;}

A 23B 69C 2I5D Compile time errorAnswer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion Where does the execution of the program starts ?A User-defined functionB Main functionC Void functionD None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion Which of the following is used to terminate the function declaration ?A :B )

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .8

Page 9: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

C Both (a) and (b)D None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion Which is more effective while calling the functions ?A Call by valueB Call by referenceC Call by pointerD None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespaces std;void mani()void main(){cout<<"hai";}int main(){mani ();return 0;}

A HaiB HaihaiC Compile time errorD None of the aboveAnswer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;void fun(int x, int y){x= 20;Y= 10;}int main(){int x = 10;

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .9

Page 10: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

fun(x, x);cout << x;return 0;}

A 10B 20C Compile time errorD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the scope of the variable declared in the user defined function ?A Whole programB Only inside the { } blockC Both A and BD None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion How many minimum number of functions is need to be presented in C++?A 0B 1C 2D 3Answer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion How many ways of passing a parameter are there in C++ ?A 1B 2C 3D 4Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion Which is used to keep the call by reference value as intact ?A StaticB ConstC AbsoluteD None of the above

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .10

Page 11: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Answer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion By default how the value are passed in C++ ?A Call by valueB Call by referenceC Call by PointerD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the new value of x ?

#include <iostream>using narnespace std;void fun(int &x){x = 20;}int main(){int x = 10;fun(x);cout << "New value of x is " << x;return 0;}

A 10B 20C 15D None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespaces std;void square (int *x){*x=(*x+ 1)*(*x);}int main ( ){int num = 10;square(&num);cout << num;

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .11

Page 12: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

return 0;A 100B Compile time errorC 144D 110Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespaces std;int add(int a, int b);int main (){inti=5, j=6;cout << add(i, j) << endl;return 0;}int add(int a, int b );{int sum = a +b;a=7;return a + b;}

A 11B 12C 13D Compile time errorAnswer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion What will happen when we use void in argument passing ?A It will not return value to its callerB It will return value to its callerC Both (a) and (b)D None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion How many types of returning values are present in C++ ?A 1B 2C 3

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .12

Page 13: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

D 4Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion What will you use if you are not intended to get a return value ? A StaticB ConstC VolatileD VoidAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Where the return statement does returns the execution of the program ?A Main functionB Caller functionC Same functionD None of the aboveAnswer Correct Option BMarks 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;int max(int a, int b ){return(a>b?a:b);}int main(){int i=5;int j = 7;cout << max(i, j );return 0;}

A 5B 7C Either (a) or (b)D None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion When will we use the function overloading ?

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .13

Page 14: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

A Same function name but different number of argumentsB Different function name but same number of argumentsC Same function name but same number of argumentsD Different function name but different number of argumentsAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program ?

#include <iostream>using namespace std;int gcd (int a, int b){int temp;while (b != 0) {temp = a %b;a=b;b = ternp;}return(a);}int main (){intx=15,y=25;cout << gcd(x, y);return(0);}

A 15B 25C 375D 5Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which of the following permits function overioading on C++ ?A TypeB Number of argumentsC Both (a) and (b)D None of the aboveAnswer Correct OptionMarks 2Unit 2

Id Keep it blankQuestion Which of the following concepts is used to impiement late binding ?A Virtual function

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .14

Page 15: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

B Operator functionC Const functionD Static functionAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion In which of the following we cannot overload the function ?A Return functionB CallerC Called functionD None of the aboveAnswer Correct OptionMarks 2Unit 2

Id Keep it blankQuestion Function overloading is also similar to which of the foilowing ?A Operator overloadingB Constructor overloadingC Destructor overloadingD None of the atroveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion How "Late binding" is implemented in C++ ?A Using C++ tablesB Using Virtual tablesC Using Indexed virtual tablesD Using polymorphic tablesAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion Q. 54 Overloaded functions are_____A Very long functions that can hardly runB One function containing another one or more functions inside it.C Two or more functions with the same name but different number of parameters or

type.D None of the aboveAnswer Correct Option CMarks 2Unit 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .15

Page 16: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep it blankQuestion What will happen while using pass by reference ?A The values of those variables are passed to the function so that it can manipulate

them. B The location of variable in memory is passed to the function so that it can use the

same memory area for its processing.C The function declaration should contain ampersand (& in its type declaration).D A-ll of these.Answer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion When our function doesn't need to return any thing means what we will as

parameter in function?A VoidB Blank spaceC Both (a) and (b)D None of theseAnswer Correct OptionMarks 2Unit 2

Id Keep it blankQuestion What are the advantages of passing arguments by reference?A Changes to parameter values within the function also affect the original arguments.B There is need to copy parameter values (i.e. less memory used.)C There is no need to call constructors for parameters (i.e. faster)D All of theseAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion If the user didn't supply the user value means, then what value will it take?A Default valueB Rise an errorC Both (a) and (b)D None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion Where does the default parameter can be placed by the user?A LeftmostB RightmostC Both (a) and (b)

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .16

Page 17: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

D None of the aboveAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion Which value will it take when both user and default values are given?A User valueB Default valueC Custom valueD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the output of this program?

#include <iostream>using namespaces std;void Values(int n1, int n2 = 10){using namespaces std;cout << "1st value: " << n1;cout << "2nd value: " << n2;}int main(){Values(1);Values(3,4);return 0;}

A 1st value: 12nd value: 101st value: 32nd value: 4

B 1s value: 12nd value: 101st value: 32nd value: 10

C Compile time errorD None of the aboveAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion What is the default return type of a function?A IntB VoidC Float

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .17

Page 18: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

D CharAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement is correct?A C++ enables to define functions that take constants as an argument'B We cannot change the argument of the function that that are declared as constant.C Both (a) and (b).D We cannot use the constant while defining the function'Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement is correct?A Overloaded functions can have at most one default argument'B An overloaded function cannot have default argumentC All arguments of an overloaded function can be defaultD A function if overloaded more than once argument cannot have defaultAnswer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement is correct?A Two functions having same number of argument, order and type of argument can

be overloaded if both functions do not have any default argument.B Overloaded function must have default arguments.C Overloaded function must have default arguments starting from the left of argument

list.D A function can be overloaded more than once.Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement will be correct if the function has three

arguments Passed to it?A The trailing argument will be the default argument'B The first argument will be the default argument'C The middle argument will be the default argument'D AII the argument will be the default argument'Answer Correct Option AMarks 2

Id Keep it blank

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .18

Page 19: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Question Where the default value of parameter have to be specifred?A Function callB Function definitionC Function prototypeD Both (b) and (c)Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement is correct?A The default value for an argument cannot be function callB C++ allows the redefinition of a default parameter'C Both (a) and (b).D C++ does not allow the redefinition of a default parameterAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement is correct?A Only one parameter of a function can be a default parameterB Minimum one parameter of a function must be a default parameterC All the parameters of a function can be default parametersD No parameter of a function can be defaultAnswer Correct Option CMarks 2

Id Keep it blankQuestion Which of the following statement is incorrect?A A default argument is checked for type at the time of declaration and

evaluated at the time of callB We can provide a default value to a particular argument in the middle of an

argument list.C We cannot provide a default value to a particular middle of an argument listD Default arguments are useful in situations where always have the same value

some argumentsAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement is correct?A Overloaded functions can accept same number of argumentsB Overloaded functions always return value of same data typeC Overloaded functions can accept only same number and same type of

arguments.D Overloaded functions can type of arguments.Answer Correct Option A

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .19

Page 20: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Marks 2

Id Keep it blankQuestion Which of the following statement is correct?A The order of the default argument will be right to left.B The order of the default argument will be ieft to right.C The order of the default argument will be alternate.D The order of the default argument will be random.Answer Correct Option AMarks 2

Id Keep it blankQuestion What happens when we try to compile the class definition in following

code snippet?

class Birds {};

class Peacock : protected Birds {};A It will not compile because class body of Birds is not defined.B It will not compile because class body of Eagle is not defined.C It will not compile because a class cannot be protected inherited from

other class.D It will compile successfully.Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which of the following statements is incorrect?A Friend key word can be used in the class to allow access to another

class.B Friend key-word can be used for a function in the public section of a

class.C Friend keyword can be used for a function in the private section of a

class-D Friend keyword can be used on main ( ).Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which of the following statement is correct regarding destructor of base

class?A Destructor of base class should always be static.B Destructor of base class should always be virtual.C Destructor of base class should not be virtual.D Destructor of base class should always be private.Answer Correct Option BMarks 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .20

Page 21: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep it blankQuestion Which of the following two entities (reading from Left to Right) can be

connected by the dot operator?A A class member and a class object.B A class object and a class.C A class and a member of that class.D A class object and a member of that class.Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion How can we make a class abstract?A By making all member functions constant.B By making at Least one member function as pure virtual function.C By declaring it abstract using the static keyword.D By declaring it abstract using the virtual keyword.Answer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion Which of the following can access private data members or member functions of a

class?A Any function in the program.B All global functions in the program.C Any member function of that class.D Only public member functions of that class.Answer Correct Option CMarks 2

Id Keep it blankQuestion Which of the following t;pe of data member can be shared by all instances

of its class?A PublicB InheritedC StaticD FriendAnswer Correct Option CMarks 2

Id Keep it blankQuestion Constructor is executed when ________.A An object is createdB An object is usedC A class is declaredD An object goes out of scope.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .21

Page 22: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Answer Correct Option AMarks 2

Id Keep it blankQuestion Which of the following statements about virtual base classes is correct?A It is used to provide multiple inheritance.B It is used to avoid multiple copies of base class in derived class.C It is used to allow multiple copies of base class in a derived class.D It allows private members of the base class to be inherited in the derived class.Answer Correct Option BMarks 2

Id Keep it blankQuestion Which of the following operators cannot be overloaded?A []B ->C ?:D *Answer Correct Option CMarks 2

Id Keep it blankQuestion which one of the following is the correct way to declare a pure virtual function?A Virtual void Display(void){0};B Virtual void Display = Q;C Virtual void Display(void) = 0;D Void Display(void) = 0;Answer Correct Option CMarks 2

Id Keep it blankQuestion Which of the following keyword is used to overload an operator?A OverloadB OperatorC FriendD OverrideAnswer Correct Option BMarks 2

Id Keep it blankQuestion Which of the following operator can not be overloaded ?A Scope resolution operatorB A now operatorC Equality operatorD Assignment operatorAnswer Correct Option AMarks 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .22

Page 23: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep it blankQuestion Pick the other name of operator function.a Function overloadingB Operator overloadingC Member overloadingD None of the aboveAnswer Correct Option BMarks 2

Id Keep it blankQuestion Which of the following operators can,t be overloaded?A ::B +C -D [ ]Answer Correct Option AMarks 2

Id Keep it blankQuestion How to declare operator function?A Operator operator signB operatorC operator signD None of the aboveAnswer Correct Option AMarks 2

Id Keep it blankQuestion What is the output of this program?

#include < iostream >using namespaces std;class sample{Public:int x, Y;sample (){} ;sample(int, int);sample operator + (sample);};sample::sample (int a,int b){x=a;y=b;}sample sample::operator+ (sample param){sample temp;temp.x=x+param.x;

temp.y=y+param.y;

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .23

Page 24: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

return(temp);}int main() {sample a (4,1);sample b (3,2);sample c;c=a+b;cout << c.x << "," << c.y;return 0;}

A 5,5B 7,3C 3,7D none of the aboveAnswer Correct Option BMarks 2

Id Keep it blankQuestion What is the return type of the conversion operator?A VoidB IntC FloatD No return typeAnswer Correct Option DMarks 2

Id Keep it blankQuestion Why we use the "dynamic_cast" type conversion?

A Result of the type conversion is a validB To be used in low memoryC Result of the type conversion is a invalidD None of theseAnswer Correct Option AMarks 2

Id Keep it blankQuestion How many parameters does a conversion operator may take?A 0B 1C 2D As many as PossibleAnswer Correct Option AMarks 2

Id Keep it blankQuestion How many types are there in user defined conversion?

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .24

Page 25: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

A 1B 2C 3D 4Answer Correct Option BMarks 2

Id Keep it blankQuestion Pick out the correct syntax of operator conversion from the following'A Operator float0constB Operator float ()C Operator constD None of theseAnswer Correct Option AMarks 2Id Keep it blankQuestion A normal C++ operator that acts in a special way on newly defined

data types is called------A encapsulatedB overload.edC classifiedD inheritedAnswer Correct Option BMarks 1Unit 2

Id Keep it blankQuestion the following operator is not overloaded in C++ ?A ++B =C powD <<Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion The correct function name for overloading the addition + operator is_.A Operator_+B Operator:+C Operator(+) D Operator+Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Which of the following operators cannot be overloaded ?

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .25

Page 26: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

A The -> operatorB The , operatorC The [ ] operatorD The & operatorAnswer Correct Option BMarks 2Unit 2

Id Keep it blankQuestion Which of the following operator can not be overloaded?A +B -C [ ]D ::Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion How to declare operator function ?A Operator operator signB OperatorC Operator signD None of theseAnswer Correct Option AMarks 4Unit 2

Id Keep it blankQuestion We cannot use friend function to overload_____A = operatorB function call operatorC subscript operatorD all of these Answer Correct Option DMarks 4Unit 2

Id Keep it blankQuestion Pick up the incorrect statement from the followingA The overloaded operators follow the syntax rules of original operator.B Only existing operators can be overloaded.C Overloaded operator must have at least one operand of its class t1pe.D Overloaded operators can change the meaning of the original operator.Answer Correct Option DMarks 4Unit 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .26

Page 27: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep it blankQuestion For operators to be overloaded as non static member functions :A Both binary and unary operators take one argument.B Binary operators c6rn have one argument and unary operators can not have any.C Neither binary nor unary operators can have argumentsD Binary operators can have two arguments and unary operators can have oneAnswer Correct Option BMarks 4Unit 2

Id Keep it blankQuestion Which of the following is an operator functionA Member overloadingB Function overloadingC Operator overloadingD None of theseAnswer Correct Option CMarks 4Unit 2

Id Keep it blankQuestion Operator overloading meansA giving new meaning to existing operator without changing its original meaning..B making C++ operators to work with objectsC making new type of operatorD both a and bAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion 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 implicitly.Answer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion Overloading a postfix increment operator by means of a member function takes_.

A no argumentB one argumentC two argument D three argument

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .27

Page 28: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Answer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion If you overload only prefix operator ++ then the postfix ++ operator is_____A does not workB works arbitrarilyC works naturallyD works as if prefix ++ operatorAnswer Correct Option DMarks 2Unit 2

Id Keep it blankQuestion When compiler decides binding of an overloaded member then it is called______A static bindingB dynamic bindingC local bindingD none of theseAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion One can redefine the working of ________ to work with objects.A preprocessor directivesB white space charactersC standard operatorsD none of theseAnswer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion Choose the correct option.

I. When you overload << operator the >> operator automatically gets overloaded.

II. You can overload unary operator to work with binary operatorA Only I is true.B Only II is true.C Both I and II are true.D Neither I nor II are true.Answer Correct Option DMarks 2Unit 2

Id Keep it blank

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .28

Page 29: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Question Choose the correct option.1) If you do not want to make use of operator overloading, you can achievethat effect using user defined function.2) The size of operator can be overloaded.

A Only 1 is true.B Only 2 is true.C Both 1 and 2 are true.D Neither 1 nor 2 are true.Answer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion the array subscript operator [ ] when The overloaded cannot_______A take user defined objects as operands.B take float as an operand.C take multiple values inside (for example [5,7]).D none of these.Answer Correct Option CMarks 4Unit 2Id Keep it blank

Id Keep It BlankQuestion The prototype of overloaded cast operator functions do not A specify the type they convert toB specify the return typeC need to be defined inside the class whose objects are being convertedD none of theseAnswer Correct option BMarks 4Unit 2Id Keep it blank A 10 20B 1 2C 11 12D 30 3Answer Correct option cMarks 2Unit 2

Id Keep it blank Question Which of the following operators cannot be overloaded ?A +=B <<C ?:D function call()Answer Correct option c

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .29

Page 30: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Marks 2Unit 2

Id Keep it blank Question Which of the following operators cannot be overloaded ?A ::B SizeofC Conditional operator ?:D All of theseAnswer Correct option BMarks 2Unit 2

Id Keep It BlankQuestion Which of the following operator can be overloaded through friend function ?A ;;B +C =D ->Answer Correct Option BMarks 2Unit 2

Id Keep It BlankQuestion The name of the operator function that overloads the / symbol is----A operator/()B /op()C /operator()D op/()Answer Correct option AMarks 2Unit 2

Id Keep It BlankQuestion Overloading means-----A 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 the aboveAnswer Correct option AMarks 2Unit 2

Id Keep It BlankQuestion The inheritance mechanism provides the means of derivingA new function from existing oneB new class from existing oneC new operator from existing one

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .30

Page 31: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

D all of these Answer Correct option BMarks 2Unit 2

Id Keep It BlankQuestion A class derived from the existing class is known asA New classB inheritedC derived classD none of theseAnswer Correct Option CMarks 2Unit 2

Id Keep It BlankQuestion What is the syntax of inheritance of a class ?A Class class_nameB Class name:access specifierC Class name:access specifier class name D None of theseAnswer Correct Option CMarks 2Unit 2

Id Keep It BlankQuestion If an attribute is private then which method have access to itA Only static methods in the same class. B Only the methods defined in that class.C Only the methods of the of the same package.D None of these.Answer Correct Option BMarks 2Unit 2

Id Keep It BlankQuestion When the object of derived class expire, first the__ is invoked followed bv the_____A derived class constructor, base class,destructorB derived class destructor, base class destructorC base class destructor, derived class destructorD none of theseAnswer Correct Option BMarks 2Unit 2

Id Keep It BlankQuestion If class A inherits from class B then B -------is called and A is called ------_ of B.A superclass and subclass

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .31

Page 32: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

B subclass and superclassC subclass and child classD superclass and parent classAnswer Correct Option AMarks 2Unit 2

Id Keep It BlankQuestion What does the derived class. does not inherit from the base class ------A constructor and destructorB Operator = () membersC friendsD all of theseAnswer Correct Option DMarks 2Unit 2

Id Keep It BlankQuestion Which constructor will initialize the base class data member ?A Base classB Derived classC Derived derived classD None of theseAnswer Correct Option AMarks 2Unit 2

Id Keep It BlankQuestion When the object of derived class expire, first the _____is invoked followed bv

the____A derived class constructor, base class destructorB derived class destructor, base class destructorC base class destructor, derived class destructorD none of theseAnswer Correct Option BMarks 2Unit 2Id Keep it blankQuestion If class A inherits from class B then B is called and A is called _ of B.A superclass and subclassB subclass and superclassC subclass and child classD superclass and parent classAnswer Correct Option AMarks 2Unit 2

Id Keep it blank

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .32

Page 33: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Question Which constructor will initialize the baseclass data member ?A Base classB Derived classC Derived derived classD None of theseAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion If class A is a friend class of class B, if class B is friend class of class C thenA class C is friend class of AB class A is friend class of class CC class A and C do not have any

friendship relation.D none of theseAnswer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion class is tightly coupled with other class.A friendB virtualC abstractD none of theseAnswer Correct Option AMarks 2Unit 2

Id Keep it blankQuestion 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 Correct Option DMarks 2Unit 2

Id Keep it blankQuestion What will be the output of the following code ?

#include <iostream.h>using namespace std;class A{public:A(int a)

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .33

Page 34: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

{cout<<” ”<<a;}};

class B: public A

{

public:

B(int a, int b):A(a){cout <<” ”<<b;}

class C: public B{public:C(int a,int b, int c):B(a,b){cout<< “ “<<c;};int main(){C c(10,20,30);return 0;}

A Garbage 30

B 30 20 10 c 10 20 30D Syntax ErrorAnswer Correct Option CMarks 2Unit 2

CId Keep it blank

QuestionABCDAnswer Correct Option

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .34

Page 35: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Marks 2Unit 2

Id Keep it blankQuestion What will happen on execution of the following code ?

class base{ };class derived:protected base{ };It will not compile as the class body of base class is not defined.

B It will not compile as the class body of derived class is not defined.C It will compile successfully.D The compilation of above code is dependent upon the type of data provided to it.Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion Which of the following advantage cannot be achieved by using multiple

inheritance ?

A polymorphismB dynamic bindingC Both AorBD None of these Answer Correct Option CMarks 2Unit 2

Id Keep it blankQuestion When the obiect of derived class expire,

first the is invoked followed

bv the

A derived class constructor, base class

destructor

B derived class destructor, base class

destructorC base class destructor, derived class

destructor

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .35

Page 36: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

D none of the aboveAnswer Correct Option BMarks 2Unit 2Id Keep it blank Question What is the output of code the following?

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

public: Base(){ cout << "In Base class" << endl;}};class Derived: public Base{public: Derived(){cout < < "In Derived class”<<endl;}};int main(){cout<<”\t Creating Base class object...”<< end1;Base b;cout <<”\t Creating Derived class object...”<<endl;Derived d;return0;}

A Creating Base class object....Creating Derived class object..In Base classIn Derived class.

B Creating Base class object....In Base classCreating Derived class object..In Base classIn Derived class.

C Creating Base class object....In Base classCreating Base class object....

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .36

Page 37: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Creating Derived class object..D Creating Base class object....

In Base classCreating Derived class object..In Base classIn Derived class.

Answer Correct option DMarks 2Unit 2

Id Keep it blankQuestion What is the output of thecode ?following

#include <iostream>using namespace std;class Base{protected:int a;public:Base(int x){a=x;}`~Base(){}class Derived: public Base{int b;public:Derived(int x, int y): Base(y){b = x;}~Derived()

{}

void display ()

{

cout << a << “ ” << b << endl;

}};

int main(){Derived obj(100,200);obj.display ();

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .37

Page 38: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

return 0;}

A 100 ,200B 200,100C syntax errorD 100,100Answer Correct Option Marks 2Unit 2

Id Keep it blankQuestion The overloading the function operator-------A requires class with operators overloadedB makes use of parameterized constructor.C allows to create objects that are syntactically like functions.D none of these. Answer Correct option AMarks 2Unit 2

Id Keep it blankQuestion Choose the incorrect statement from the following.

A Constructors can be overloaded.B Only existing operators can be overloaded.C The overloaded operator must follow the syntax rules of original operator operatorsD The overloaded operators must have at least one operand of its class type.Answer Correct option bMarks 2Unit 2

Id Keep it blankQuestion Wirer, base class pointer points to derived class object

t ------A it can access only base classes membersB it can access only derived class membersC both base class and derived class membersD none of theseAnswer Correct Option aMarks 4 Id Keep it blankQuestion The base class will offer A more specific objects than the derived classB more generalized version of itsC empty template of its derived classD none of these

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .38

Page 39: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Answer Correct Option dMarks 2 Id Keep it blankQuestion The hybrid inheritance isA multiple inheritanceB multilevel inheritanceC multi-path inheritanceD both a&cAnswer Correct Option dMarks 4 Id Keep it blankQuestion How many types of inheritances is there?A 1B 2C 4D 5Answer Correct Option dMarks 2 Id Keep it blankQuestion Choose the correct option.A A constructor cannot be called explicitly,B A destructor is not inherited.C Constructor cannot be inherited.D all of theseAnswer Correct Option dMarks 4 Id Keep it blankQuestion Suppose class Derived is derived from a class Base. Both the classes contain the

function named display0 that takes no argument. What will be the statement inthe class Derived which will call the disolavO function of Base class f J--

A display0B base: display0C base::display0D can make such callAnswer Correct Option cMarks 4Unit Unit 2

Id Keep It BlankQuestion Suppose class Derived is derived from a class Base privately. The object of class

Derived is located in main$ c:rn accessA public members of BaseB private members of BaseC protected members of Base

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .39

Page 40: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

D public members of DerivedAnswer Correct Option dMarks 2Unit 2

Id Keep It BlankQuestion Multiple inheritance causes for a derived class to have mernbers.A ambiguousB publicC privateD protectedAnswer Correct Option aMarks 2Unit 2

Id Keep It BlankQuestion What will be the first line of specifier for the class tier, wheel and rubber. Make

use of public inheritance.A Class Tier:public wheel, public rubberB Class wheel:public Tier, public rubberC Class rubber:public Tier, public wheelD none of theseAnswer Correct Option aMarks 2Unit 2

Id Keep It BlankQuestion Which is the correct class definition for class C, which inherits from A and B

classes ?A Class C:A,BB Class C::A,BC Class C:public A,public BD Class C::public A,public BAnswer Correct Option cMarks 2Unit 2

Id Keep It BlankQuestion ability of a function The in different ways on act type is called as _.

or operator to different dataA inheritanceB polymorphismC encapsulationD none of theseAnswer Correct Option bMarks 2Unit 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .40

Page 41: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Id Keep It BlankQuestion class that declare or inherits a virtual function____A Encapsulated classB Inherited classC Polymorphic classD None of theseAnswer Correct Option cMarks 2Unit 2

Id Keep It BlankQuestion Choose the correct option.A A base class may have more than one derived class.B Derived class may have more than one base class.C Both a and b.D neither a and b.Answer Correct Option cMarks 2Unit 2

Id Keep It Blank Question Which of the following advantage we lose by using multiple inheritance ?A PolymorphismB Dynamic bindingC Both a and bD none of theseAnswer Correct Option cMarks 2Unit 2

Id Keep It BlankQuestion Overloading is a form ofA virtual polymorphismB Transient polymorphismC ad-hoc polymorphismD none of theseAnswer Correct Option cMarks 2Unit 2

Id Keep It BlankQuestion constructor for the derived class must be providedA if base class constructor required argumentsB if base class constructor required argumentsC neverD alwaysAnswer Correct Option aMarks 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .41

Page 42: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Unit 2

Id Keep it blankQuestion functions are bounded dynamically at run time.A StaticB friend C InlineD virtualAnswer Correct Option dMarks 2Unit 2

Id Keep it blankQuestion A virtual function allows you toA create array of pointer to base class that can hold pointers to derived classes.B create functions that can never be accessible.C use same function call to execute member functions of objects from different classesD none of theseAnswer Correct Option cMarks 2Unit 2

Id Keep it blankQuestion A pure virtual function is a function thatA causes its class to be abstractB returns nothingC takes no argumentD none of theseAnswer Correct Option aMarks 2Unit 2

Id Keep it blankQuestion An abstract class is useful whenA no classes should be derived from itB there are multiple paths from one derived class to anotherC no objects can be instantiated from it.D none of theseAnswer Correct OptionMarks 2Unit 2

Id Keep it blankQuestion Choose the correct statement.A An abstract base class can have pure virtual destructorB An abstract base class can have virtual destructorC An abstract base class can have non virtual destructorD An abstract base class cannot have destructor

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .42

Page 43: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

Answer Correct Option dMarks 2Unit 2

Id Keep it blankQuestion compiler identifies the virtual The function to be pureA if the keyword pure is presentB its location in the programC if it is equal to 0D none of theseAnswer Correct Option cMarks 2Unit 2

Id Keep it blankQuestion Appropriate polymorphism For mechanism, a method in base class must be declared

_.A publicB protected C privateD virtualAnswer Correct Option dMarks 2Unit 2

Id Keep it blankQuestion A virtual function is a member function that expects to be in a derived class.A publicB overriddenC privateD virtualAnswer Correct Option bMarks 2Unit 2

Id Keep it blankQuestion The keyword virtual indicates thatA more than one base class existsB base class should be used only once in inheritanceC a derived class has public access to base classD none of theseAnswer Correct Option dMarks 2Unit 2

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .43

Page 44: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .44

Page 45: UNIT-2 Syllabus for Unit-2 Reference Book. · UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, ... Question

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .45