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

Similar documents
OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:

Module Operator Overloading and Type Conversion. Table of Contents

C++ Important Questions with Answers

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Short Notes of CS201

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

CS201 - Introduction to Programming Glossary By

Increases Program Structure which results in greater reliability. Polymorphism

Inheritance, and Polymorphism.

CS304 Object Oriented Programming Final Term

AN OVERVIEW OF C++ 1

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Object-Oriented Design (OOD) and C++

Object Oriented Programming

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT

Polymorphism Part 1 1

KLiC C++ Programming. (KLiC Certificate in C++ Programming)

Object Oriented Programming. Solved MCQs - Part 2

Reference Parameters A reference parameter is an alias for its corresponding argument in the function call. Use the ampersand (&) to indicate that

STRUCTURING OF PROGRAM

CS304 Object Oriented Programming

Syllabus of C++ Software for Hands-on Learning: This course offers the following modules: Module 1: Getting Started with C++ Programming

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Interview Questions of C++

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

CS201- Introduction to Programming Current Quizzes


I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

Instantiation of Template class

W3101: Programming Languages C++ Ramana Isukapalli

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

CS 162, Lecture 25: Exam II Review. 30 May 2018

Object Oriented Programming with c++ Question Bank

Recharge (int, int, int); //constructor declared void disply();

Absolute C++ Walter Savitch

POLYMORPHISM 2 PART. Shared Interface. Discussions. Abstract Base Classes. Abstract Base Classes and Pure Virtual Methods EXAMPLE

POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.

Note 12/1/ Review of Inheritance Practice: Please write down 10 most important facts you know about inheritance...

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Fast Introduction to Object Oriented Programming and C++

VIRTUAL FUNCTIONS Chapter 10

What is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

1 Shyam sir JAVA Notes

6.096 Introduction to C++ January (IAP) 2009

PESIT Bangalore South Campus

Constructor - example

UNIT- 3 Introduction to C++

Distributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes

What are the characteristics of Object Oriented programming language?

B.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET

Midterm Exam 5 April 20, 2015

C++_ MARKS 40 MIN

Introduction to C++ Systems Programming

Ch02. True/False Indicate whether the statement is true or false.

Chapter 15 - C++ As A "Better C"

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS

C++ Programming: Polymorphism

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

C++ 8. Constructors and Destructors

Passing arguments to functions by. const member functions const arguments to a function. Function overloading and overriding Templates

Introduction to Programming Using Java (98-388)

Padasalai.Net s Model Question Paper

Operator overloading

An Object Oriented Programming with C

Object-Oriented Principles and Practice / C++

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

C++ Memory Map. A pointer is a variable that holds a memory address, usually the location of another variable in memory.

UNIT-2 Introduction to C++

Introduction Of Classes ( OOPS )

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

IS0020 Program Design and Software Tools Midterm, Fall, 2004

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

Get Unique study materials from

CGS 2405 Advanced Programming with C++ Course Justification

+2 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1

KOM3191 Object Oriented Programming Dr Muharrem Mercimek OPERATOR OVERLOADING. KOM3191 Object-Oriented Programming

G52CPP C++ Programming Lecture 13

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

Lecture-5. Miscellaneous topics Templates. W3101: Programming Languages C++ Ramana Isukapalli

CS201 Latest Solved MCQs

CS201 Some Important Definitions

Chapter 11: More About Classes and Object-Oriented Programming

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name:

Tokens, Expressions and Control Structures

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

Programming in C++: Assignment Week 4

Transcription:

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 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 Which operator is having the highest precedence? A Postfix B Unary C shift D Equality Operator?: is known as A Conditional B Relational C Casting operator DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..1

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 20 C 25 D 30 What is the use of dynamic_cast operator? A It converts virtual base class to derived class B It converts virtual base object to a derived object C It will convert the operator based on precedence 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 6 B 6 5 C 6 7 What is the output ofthis program? DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..2

#include <iostream> using namespace std; int main ( ) int i, j; j =10; i= (j++,j+ 100,999 +j); cout<<i; return 0; A 1000 B 11 C 1010 D 1001 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 10 How many sequences of statements are present in c++? A 4 B 3 C 5 D 6 DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..3

The if..else statement can be replaced by which operator? A Bitwise operator B Conditional operator C Multiplicative operator The switch statement is also called as? A Choosing structure B Selective structure C Certain structure The destination statement for the goto label is identified by what label? A $ B @ C * D : Answer Correct Option D 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 543 B 54 C 5432 DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..4

D 53 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 1010 B 10 C Infinitely print 10 D Compile time error Answer Correct Option D What is the output of this program? #include <iostream> using namespace std; int main () int n = l5; for(; ;) cout << n; return 0; A Error B 15 C Infinite times of printing n DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..5

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 0123456789 B 10 C 012345678910 D Compile time error How many types of loops are there? A 4 B 2 C 3 D 1 Which looping Process is best used when the number of iterations is known? A For B while C Do-while D All looping processes require that the iterations be known How many types of comments are there in C++? A 1 B 2 C 3 D 4 DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..6

What is a comment in c++? A Comments are parts of the source code disregarded by the compiler B Comments are executed by compiler to find the meaning of the comment C Comments are executable What type of comments does c++ support? A Single line B Multi line C Single line and multi line What is the output of this program? #include <iostream> using namespace std; int main () /+ this is comment* cout << "hello world ; return 0; A Hello world B hello C Compile time error What is used to write multi line comment in c++? A * B \ C Both A and B DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..7

What will happen when we use void in argument passing? A It will not return value to its caller B It will return value to its caller C Both (a) and (b) are correct 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 23 B 69 C 2I5 D Compile time error Where does the execution of the program starts? A User-defined function B Main function C Void function 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

C Both (a) and (b) Which is more effective while calling the functions? A Call by value B Call by reference C Call by pointer What is the output of this program? #include <iostream> using namespaces std; void mani() void main() cout<<"hai"; int main() mani (); return 0; A Hai B Haihai C Compile time error 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

fun(x, x); cout << x; return 0; A 10 B 20 C Compile time error What is the scope of the variable declared in the user defined function? A Whole program B Only inside the block C Both A and B How many minimum number of functions is need to be presented in C++? A 0 B 1 C 2 D 3 How many ways of passing a parameter are there in C++? A 1 B 2 C 3 D 4 Which is used to keep the call by reference value as intact? A Static B Const C Absolute DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..10

By default how the value are passed in C++? A Call by value B Call by reference C Call by Pointer 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 10 B 20 C 15 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

return 0; A 100 B Compile time error C 144 D 110 Answer Correct Option D 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 11 B 12 C 13 D Compile time error What will happen when we use void in argument passing? A It will not return value to its caller B It will return value to its caller C Both (a) and (b) How many types of returning values are present in C++? A 1 B 2 C 3 DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..12

D 4 What will you use if you are not intended to get a return value? A Static B Const C Volatile D Void Answer Correct Option D Where the return statement does returns the execution of the program? A Main function B Caller function C Same function 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 5 B 7 C Either (a) or (b) When will we use the function overloading? DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..13

A Same function name but different number of arguments B Different function name but same number of arguments C Same function name but same number of arguments D Different function name but different number of arguments 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 15 B 25 C 375 D 5 Answer Correct Option D Which of the following permits function overioading on C++? A Type B Number of arguments C Both (a) and (b) Answer Correct Option 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

B Operator function C Const function D Static function In which of the following we cannot overload the function? A Return function B Caller C Called function Answer Correct Option Function overloading is also similar to which of the foilowing? A Operator overloading B Constructor overloading C Destructor overloading D None of the atrove How "Late binding" is implemented in C++? A Using C++ tables B Using Virtual tables C Using Indexed virtual tables D Using polymorphic tables A B C D Answer Q. 54 Overloaded functions are Very long functions that can hardly run One function containing another one or more functions inside it. Two or more functions with the same name but different number of parameters or type. None of the above Correct Option C DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..15

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. A B C D Answer When our function doesn't need to return any thing means what we will as parameter in function? Void Blank space Both (a) and (b) None of these Correct Option 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 these Answer Correct Option D If the user didn't supply the user value means, then what value will it take? A Default value B Rise an error C Both (a) and (b) A B C Where does the default parameter can be placed by the user? Leftmost Rightmost Both (a) and (b) DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..16

Which value will it take when both user and default values are given? A User value B Default value C Custom value 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: 1 2nd value: 10 1st value: 3 2nd value: 4 B 1s value: 1 2nd value: 10 1st value: 3 2nd value: 10 C D Answer Compile time error None of the above Correct Option A A B C What is the default return type of a function? Int Void Float DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..17

D Char 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' Which of the following statement is correct? A Overloaded functions can have at most one default argument' B An overloaded function cannot have default argument C All arguments of an overloaded function can be default D A function if overloaded more than once argument cannot have default A B C D Answer Which of the following statement is correct? Two functions having same number of argument, order and type of argument can be overloaded if both functions do not have any default argument. Overloaded function must have default arguments. Overloaded function must have default arguments starting from the left of argument list. A function can be overloaded more than once. Correct Option D 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' DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..18

Where the default value of parameter have to be specifred? A Function call B Function definition C Function prototype D Both (b) and (c) Which of the following statement is correct? A The default value for an argument cannot be function call B C++ allows the redefinition of a default parameter' C Both (a) and (b). D C++ does not allow the redefinition of a default parameter Answer Correct Option D Which of the following statement is correct? A Only one parameter of a function can be a default parameter B Minimum one parameter of a function must be a default parameter C All the parameters of a function can be default parameters D No parameter of a function can be default 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 call B 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 list D Default arguments are useful in situations where always have the same value some arguments Answer Correct Option D Which of the following statement is correct? A Overloaded functions can accept same number of arguments B Overloaded functions always return value of same data type C Overloaded functions can accept only same number and same type of arguments. D Overloaded functions can type of arguments. DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..19

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. 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 D A B Which of the following statements is incorrect? Friend key word can be used in the class to allow access to another class. 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 D 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. DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..20

A B C D Answer Which of the following two entities (reading from Left to Right) can be connected by the dot operator? A class member and a class object. A class object and a class. A class and a member of that class. A class object and a member of that class. Correct Option D 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. 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. Which of the following t;pe of data member can be shared by all instances of its class? A Public B Inherited C Static D Friend A B C D Constructor is executed when. An object is created An object is used A class is declared An object goes out of scope. DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..21

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. Which of the following operators cannot be overloaded? A [] B -> C?: D * 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; Which of the following keyword is used to overload an operator? A Overload B Operator C Friend D Override Which of the following operator can not be overloaded? A Scope resolution operator B A now operator C Equality operator D Assignment operator DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..22

Pick the other name of operator function. a Function overloading B Operator overloading C Member overloading Which of the following operators can,t be overloaded? A :: B + C - D [ ] How to declare operator function? A Operator operator sign B operator C operator sign 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

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,5 B 7,3 C 3,7 D none of the above What is the return type of the conversion operator? A Void B Int C Float D No return type Answer Correct Option D Why we use the "dynamic_cast" type conversion? A Result of the type conversion is a valid B To be used in low memory C Result of the type conversion is a invalid D None of these How many parameters does a conversion operator may take? A 0 B 1 C 2 D As many as Possible How many types are there in user defined conversion? DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..24

A 1 B 2 C 3 D 4 Pick out the correct syntax of operator conversion from the following' A Operator float0const B Operator float () C Operator const D None of these A normal C++ operator that acts in a special way on newly defined data types is called------ A encapsulated B overload.ed C classified D inherited Marks 1 the following operator is not overloaded in C++? A ++ B = C pow D << The correct function name for overloading the addition + operator is_. A Operator_+ B Operator:+ C Operator(+) D Operator+ Answer Correct Option D Which of the following operators cannot be overloaded? DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..25

A The -> operator B The, operator C The [ ] operator D The & operator Which of the following operator can not be overloaded? A + B - C [ ] D :: Answer Correct Option D How to declare operator function? A Operator operator sign B Operator C Operator sign D None of these Marks 4 We cannot use friend function to overload A = operator B function call operator C subscript operator D all of these Answer Correct Option D Marks 4 Pick up the incorrect statement from the following A 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 D Marks 4 DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..26

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 arguments D Binary operators can have two arguments and unary operators can have one Marks 4 Which of the following is an operator function A Member overloading B Function overloading C Operator overloading D None of these Marks 4 Operator overloading means A giving new meaning to existing operator without changing its original meaning.. B making C++ operators to work with objects C making new type of operator D both a and b Answer Correct Option D For overloading += implicitly A + and = operators need to be overloaded implicitly B only + operator need to be overloaded implicitly C only = operator need to be overloaded implicitly D the +- operator cannot be overloaded implicitly. Answer Correct Option D Overloading a postfix increment operator by means of a member function takes_. A B C D no argument one argument two argument three argument DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..27

If you overload only prefix operator ++ then the postfix ++ operator is A does not work B works arbitrarily C works naturally D works as if prefix ++ operator Answer Correct Option D When compiler decides binding of an overloaded member then it is called A static binding B dynamic binding C local binding D none of these One can redefine the working of to work with objects. A preprocessor directives B white space characters C standard operators D none of these Choose the correct option. I. When you overload << operator the >> operator automatically gets overloaded. II. You can overload unary operator to work with binary operator A 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 D DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..28

Choose the correct option. 1) If you do not want to make use of operator overloading, you can achieve that 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. 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. Marks 4 Keep It Blank The prototype of overloaded cast operator functions do not A specify the type they convert to B specify the return type C need to be defined inside the class whose objects are being converted D none of these Answer Correct option B Marks 4 A 10 20 B 1 2 C 11 12 D 30 3 Answer Correct option c 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

Which of the following operators cannot be overloaded? A :: B Sizeof C Conditional operator?: D All of these Answer Correct option B Keep It Blank Which of the following operator can be overloaded through friend function? A ;; B + C = D -> Keep It Blank The name of the operator function that overloads the / symbol is---- A operator/() B /op() C /operator() D op/() Answer Correct option A Keep It Blank Overloading means----- A two or more methods in the same class that have same name B calling the method which has actual parameters C two or more methods having same name but present in different class D none of the above Answer Correct option A A B C Keep It Blank The inheritance mechanism provides the means of deriving new function from existing one new class from existing one new operator from existing one DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..30

D all of these Answer Correct option B Keep It Blank A class derived from the existing class is known as A New class B inherited C derived class D none of these Keep It Blank What is the syntax of inheritance of a class? A Class class_name B Class name:access specifier C Class name:access specifier class name D None of these Keep It Blank If an attribute is private then which method have access to it A 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. Keep It Blank When the object of derived class expire, first the is invoked followed bv the A derived class constructor, base class,destructor B derived class destructor, base class destructor C base class destructor, derived class destructor D none of these Keep It Blank 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

B subclass and superclass C subclass and child class D superclass and parent class Keep It Blank What does the derived class. does not inherit from the base class ------ A constructor and destructor B Operator = () members C friends D all of these Answer Correct Option D Keep It Blank Which constructor will initialize the base class data member? A Base class B Derived class C Derived derived class D None of these Keep It Blank When the object of derived class expire, first the is invoked followed bv the derived class constructor, base class destructor derived class destructor, base class destructor base class destructor, derived class destructor none of these A B C D If class A inherits from class B then B is called and A is called _ of B. A superclass and subclass B subclass and superclass C subclass and child class D superclass and parent class DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..32

Which constructor will initialize the baseclass data member? A Base class B Derived class C Derived derived class D None of these A B C If class A is a friend class of class B, if class B is friend class of class C then class C is friend class of A class A is friend class of class C class A and C do not have any friendship relation. D none of these class is tightly coupled with other class. A friend B virtual C abstract D none of these keyword friend is used in A the class allowing access to another class B the private section of a class C the public section of a class D all of these Answer Correct Option D 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

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 30 D Syntax Error C A B C D Answer Correct Option DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..34

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. Which of the following advantage cannot be achieved by using multiple inheritance? A polymorphism B dynamic binding C Both AorB D None of these When the obiect of derived class expire, first the is invoked followed bv the A derived class constructor, base class destructor B C derived class destructor, base class destructor base class destructor, derived class destructor DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..35

D none of the above 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 B C Creating Base class object... Creating Derived class object.. In Base class In Derived class. Creating Base class object... In Base class Creating Derived class object.. In Base class In Derived class. Creating Base class object... In Base class Creating Base class object... DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..36

Creating Derived class object.. D Creating Base class object... In Base class Creating Derived class object.. In Base class In Derived class. Answer Correct option D 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

return 0; A 100,200 B 200,100 C syntax error D 100,100 Answer Correct Option The overloading the function operator------- A requires class with operators overloaded B makes use of parameterized constructor. C allows to create objects that are syntactically like functions. D none of these. Answer Correct option A 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 operators D The overloaded operators must have at least one operand of its class type. Answer Correct option b Wirer, base class pointer points to derived class object t ------ A it can access only base classes members B it can access only derived class members C both base class and derived class members D none of these Answer Correct Option a Marks 4 The base class will offer A more specific objects than the derived class B more generalized version of its C empty template of its derived class D none of these DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..38

Answer Correct Option d The hybrid inheritance is A multiple inheritance B multilevel inheritance C multi-path inheritance D both a&c Answer Correct Option d Marks 4 How many types of inheritances is there? A 1 B 2 C 4 D 5 Answer Correct Option d 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 these Answer Correct Option d Marks 4 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 in the class Derived which will call the disolavo function of Base class f J-- A display0 B base: display0 C base::display0 D can make such call Answer Correct Option c Marks 4 Unit A B C Keep It Blank Suppose class Derived is derived from a class Base privately. The object of class Derived is located in main$ c:rn access public members of Base private members of Base protected members of Base DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..39

D public members of Derived Answer Correct Option d Keep It Blank Multiple inheritance causes for a derived class to have mernbers. A ambiguous B public C private D protected Answer Correct Option a Keep It Blank 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 rubber B Class wheel:public Tier, public rubber C Class rubber:public Tier, public wheel D none of these Answer Correct Option a Keep It Blank Which is the correct class definition for class C, which inherits from A and B classes? Class C:A,B Class C::A,B Class C:public A,public B A B C D Class C::public A,public B Answer Correct Option c Keep It Blank ability of a function The in different ways on act type is called as _. or operator to different data inheritance polymorphism encapsulation none of these A B C D Answer Correct Option b DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..40

Keep It Blank class that declare or inherits a virtual function A Encapsulated class B Inherited class C Polymorphic class D None of these Answer Correct Option c Keep It Blank 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 c Keep It Blank Which of the following advantage we lose by using multiple inheritance? A Polymorphism B Dynamic binding C Both a and b D none of these Answer Correct Option c Keep It Blank Overloading is a form of A virtual polymorphism B Transient polymorphism C ad-hoc polymorphism D none of these Answer Correct Option c Keep It Blank constructor for the derived class must be provided A if base class constructor required arguments B if base class constructor required arguments C never D always Answer Correct Option a DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..41

functions are bounded dynamically at run time. A Static B friend C Inline D virtual Answer Correct Option d A virtual function allows you to A 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 classes D none of these Answer Correct Option c A pure virtual function is a function that A causes its class to be abstract B returns nothing C takes no argument D none of these Answer Correct Option a An abstract class is useful when A no classes should be derived from it B there are multiple paths from one derived class to another C no objects can be instantiated from it. D none of these Answer Correct Option A B C D Choose the correct statement. An abstract base class can have pure virtual destructor An abstract base class can have virtual destructor An abstract base class can have non virtual destructor An abstract base class cannot have destructor DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..42

Answer Correct Option d compiler identifies the virtual The function to be pure A if the keyword pure is present B its location in the program C if it is equal to 0 D none of these Answer Correct Option c Appropriate polymorphism For mechanism, a method in base class must be declared _. A public B protected C private D virtual Answer Correct Option d A virtual function is a member function that expects to be in a derived class. A public B overridden C private D virtual Answer Correct Option b The keyword virtual indicates that A more than one base class exists B base class should be used only once in inheritance C a derived class has public access to base class D none of these Answer Correct Option d DEPARTMENT OF COMPUTER ENGINEERING, MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK, PAGE NO..43

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

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