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

Size: px
Start display at page:

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

Transcription

1 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 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

2 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

3 #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 = ; float b = 10.20; int c,d ; c = (int) a; d = (int) b; cout << c <<'t'<< d; return 0; A B C 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

4 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 $ 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

5 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

6 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 B 10 C 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

7 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

8 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

9 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

10 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

11 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

12 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

13 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

14 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

15 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

16 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

17 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

18 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

19 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

20 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

21 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

22 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

23 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

24 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

25 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

26 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

27 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

28 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

29 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 B 1 2 C 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

30 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

31 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

32 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

33 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

34 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 c 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

35 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

36 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

37 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

38 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

39 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

40 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

41 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

42 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

43 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

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

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

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

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

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:

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: Unit IV Pointers and Polymorphism in C++ Concepts of Pointer: A pointer is a variable that holds a memory address of another variable where a value lives. A pointer is declared using the * operator before

More information

Module Operator Overloading and Type Conversion. Table of Contents

Module Operator Overloading and Type Conversion. Table of Contents 1 Module - 33 Operator Overloading and Type Conversion Table of Contents 1. Introduction 2. Operator Overloading 3. this pointer 4. Overloading Unary Operators 5. Overloading Binary Operators 6. Overloading

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

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

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions. Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'

More information

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Object-Oriented Programming (OOP) Fundamental Principles of OOP Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is

More information

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

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

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

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University) Estd: 1994 JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli - 621014 (An approved by AICTE and Affiliated to Anna University) ISO 9001:2000 Certified Subject Code & Name : CS 1202

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Increases Program Structure which results in greater reliability. Polymorphism

Increases Program Structure which results in greater reliability. Polymorphism UNIT 4 C++ Inheritance What is Inheritance? Inheritance is the process by which new classes called derived classes are created from existing classes called base classes. The derived classes have all the

More information

Inheritance, and Polymorphism.

Inheritance, and Polymorphism. Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

AN OVERVIEW OF C++ 1

AN OVERVIEW OF C++ 1 AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function

More information

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

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction

More information

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name

More information

Object-Oriented Design (OOD) and C++

Object-Oriented Design (OOD) and C++ Chapter 2 Object-Oriented Design (OOD) and C++ At a Glance Instructor s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Questions Projects to Assign

More information

Object Oriented Programming

Object Oriented Programming Object Oriented Programming Course Title: Object Oriented Programming Full Marks: 60 20 20 Course No: CSC161 Pass Marks: 24 8 8 Nature of Course: Theory Lab Credit Hrs: 3 Semester: II Course Description:

More information

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

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT Two Mark Questions UNIT - I 1. DEFINE ENCAPSULATION. Encapsulation is the process of combining data and functions

More information

Polymorphism Part 1 1

Polymorphism Part 1 1 Polymorphism Part 1 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid

More information

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

KLiC C++ Programming. (KLiC Certificate in C++ Programming) KLiC C++ Programming (KLiC Certificate in C++ Programming) Turbo C Skills: Pre-requisite Knowledge and Skills, Inspire with C Programming, Checklist for Installation, The Programming Languages, The main

More information

Object Oriented Programming. Solved MCQs - Part 2

Object Oriented Programming. Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What

More information

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

Reference Parameters A reference parameter is an alias for its corresponding argument in the function call. Use the ampersand (&) to indicate that Reference Parameters There are two ways to pass arguments to functions: pass-by-value and pass-by-reference. pass-by-value A copy of the argument s value is made and passed to the called function. Changes

More information

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

More information

CS304 Object Oriented Programming

CS304 Object Oriented Programming 1 CS304 Object Oriented Programming 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes?

More information

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

Syllabus of C++ Software for Hands-on Learning: This course offers the following modules: Module 1: Getting Started with C++ Programming Syllabus of C++ Software for Hands-on Learning: Borland C++ 4.5 Turbo C ++ V 3.0 This course offers the following modules: Module 1: Getting Started with C++ Programming Audience for this Course Job Roles

More information

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

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

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

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object

More information

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

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity. OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

More information

CS201- Introduction to Programming Current Quizzes

CS201- Introduction to Programming Current Quizzes CS201- Introduction to Programming Current Quizzes Q.1 char name [] = Hello World ; In the above statement, a memory of characters will be allocated 13 11 12 (Ans) Q.2 A function is a block of statements

More information

Department of Computer science and Engineering Sub. Name: Object oriented programming and data structures Sub. Code: EC6301 Sem/Class: III/II-ECE Staff name: M.Kavipriya Two Mark Questions UNIT-1 1. List

More information

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

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++ No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)

More information

Instantiation of Template class

Instantiation of Template class Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double

More information

W3101: Programming Languages C++ Ramana Isukapalli

W3101: Programming Languages C++ Ramana Isukapalli Lecture-6 Operator overloading Namespaces Standard template library vector List Map Set Casting in C++ Operator Overloading Operator overloading On two objects of the same class, can we perform typical

More information

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

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS JAN 28,2011 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 FINALTERM EXAMINATION 14 Feb, 2011 CS304- Object Oriented

More information

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

CS 162, Lecture 25: Exam II Review. 30 May 2018 CS 162, Lecture 25: Exam II Review 30 May 2018 True or False Pointers to a base class may be assigned the address of a derived class object. In C++ polymorphism is very difficult to achieve unless you

More information

Object Oriented Programming with c++ Question Bank

Object Oriented Programming with c++ Question Bank Object Oriented Programming with c++ Question Bank UNIT-1: Introduction to C++ 1. Describe the following characteristics of OOP. i Encapsulation ii Polymorphism, iii Inheritance 2. Discuss function prototyping,

More information

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

Recharge (int, int, int); //constructor declared void disply(); Constructor and destructors in C++ Constructor Constructor is a special member function of the class which is invoked automatically when new object is created. The purpose of constructor is to initialize

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

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

POLYMORPHISM 2 PART. Shared Interface. Discussions. Abstract Base Classes. Abstract Base Classes and Pure Virtual Methods EXAMPLE Abstract Base Classes POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors class B { // base class virtual void m( ) =0; // pure virtual function class D1 : public

More information

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

POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors CSC 330 OO Software Design 1 Abstract Base Classes class B { // base class virtual void m( ) =0; // pure virtual

More information

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

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p. Preface to the Second Edition p. iii Preface to the First Edition p. vi Brief Contents p. ix Introduction to C++ p. 1 A Review of Structures p. 1 The Need for Structures p. 1 Creating a New Data Type Using

More information

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

Note 12/1/ Review of Inheritance Practice: Please write down 10 most important facts you know about inheritance... CISC 2000 Computer Science II Fall, 2014 Note 12/1/2014 1 Review of Inheritance Practice: Please write down 10 most important facts you know about inheritance... (a) What s the purpose of inheritance?

More information

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

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++

More information

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

VIRTUAL FUNCTIONS Chapter 10

VIRTUAL FUNCTIONS Chapter 10 1 VIRTUAL FUNCTIONS Chapter 10 OBJECTIVES Polymorphism in C++ Pointers to derived classes Important point on inheritance Introduction to virtual functions Virtual destructors More about virtual functions

More information

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

What is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1 Polymorphism Part 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid adult

More information

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming

More information

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

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus USN 1 P E PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of ECE INTERNAL ASSESSMENT TEST 2 Date : 03/10/2017 Marks: 40 Subject & Code : Object Oriented Programming

More information

Constructor - example

Constructor - example Constructors A constructor is a special member function whose task is to initialize the objects of its class. It is special because its name is same as the class name. The constructor is invoked whenever

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

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

Distributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes Distributed Real-Time Control Systems Lecture 17 C++ Programming Intro to C++ Objects and Classes 1 Bibliography Classical References Covers C++ 11 2 What is C++? A computer language with object oriented

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

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

B.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET B.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET Course Outline The main objective of this course is to introduce students to the basic concepts of a selected language

More information

Midterm Exam 5 April 20, 2015

Midterm Exam 5 April 20, 2015 Midterm Exam 5 April 20, 2015 Name: Section 1: Multiple Choice Questions (24 pts total, 3 pts each) Q1: Which of the following is not a kind of inheritance in C++? a. public. b. private. c. static. d.

More information

C++_ MARKS 40 MIN

C++_ MARKS 40 MIN C++_16.9.2018 40 MARKS 40 MIN https://tinyurl.com/ya62ayzs 1) Declaration of a pointer more than once may cause A. Error B. Abort C. Trap D. Null 2Whice is not a correct variable type in C++? A. float

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

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

Ch02. True/False Indicate whether the statement is true or false. Ch02 True/False Indicate whether the statement is true or false. 1. The base class inherits all its properties from the derived class. 2. Inheritance is an is-a relationship. 3. In single inheritance,

More information

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

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

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

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING YEAR/SEM:II & III UNIT I 1) Give the evolution diagram of OOPS concept. 2) Give some

More information

C++ Programming: Polymorphism

C++ Programming: Polymorphism C++ Programming: Polymorphism 2018 년도 2 학기 Instructor: Young-guk Ha Dept. of Computer Science & Engineering Contents Run-time binding in C++ Abstract base classes Run-time type identification 2 Function

More information

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

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 Introduction p. xxix 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 Language p. 6 C Is a Programmer's Language

More information

C++ 8. Constructors and Destructors

C++ 8. Constructors and Destructors 8. Constructors and Destructors C++ 1. When an instance of a class comes into scope, the function that executed is. a) Destructors b) Constructors c) Inline d) Friend 2. When a class object goes out of

More information

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

Passing arguments to functions by. const member functions const arguments to a function. Function overloading and overriding Templates Lecture-4 Inheritance review. Polymorphism Virtual functions Abstract classes Passing arguments to functions by Value, pointers, refrence const member functions const arguments to a function Function overloading

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Padasalai.Net s Model Question Paper

Padasalai.Net s Model Question Paper Padasalai.Net s Model Question Paper STD: XII VOLUME - 2 MARKS: 150 SUB: COMPUTER SCIENCE TIME: 3 HRS PART I Choose the correct answer: 75 X 1 = 75 1. Which of the following is an object oriented programming

More information

Operator overloading

Operator overloading 1 Introduction 2 The copy constructor 3 Operator Overloading 4 Eg 1: Adding two vectors 5 The -> operator 6 The this pointer 7 Overloading = 8 Unary operators 9 Overloading for the matrix class 10 The

More information

An Object Oriented Programming with C

An Object Oriented Programming with C An Object Oriented Programming with C By Tanmay Kasbe Dr. Ravi Singh Pippal IDEA PUBLISHING WWW.ideapublishing.in i Publishing-in-support-of, IDEA PUBLISHING Block- 9b, Transit Flats, Hudco Place Extension

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer June 3, 2013 OOPP / C++ Lecture 9... 1/40 Const Qualifiers Operator Extensions Polymorphism Abstract Classes Linear Data Structure Demo Ordered

More information

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

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103

More information

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

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

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

C++ Memory Map. A pointer is a variable that holds a memory address, usually the location of another variable in memory. Pointer C++ Memory Map Once a program is compiled, C++ creates four logically distinct regions of memory: Code Area : Area to hold the compiled program code Data Area : Area to hold global variables Stack

More information

UNIT-2 Introduction to C++

UNIT-2 Introduction to C++ UNIT-2 Introduction to C++ C++ CHARACTER SET Character set is asset of valid characters that a language can recognize. A character can represents any letter, digit, or any other sign. Following are some

More information

Introduction Of Classes ( OOPS )

Introduction Of Classes ( OOPS ) Introduction Of Classes ( OOPS ) Classes (I) A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions. An object is an instantiation of a class.

More information

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

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns This Advanced C++ Programming training course is a comprehensive course consists of three modules. A preliminary module reviews

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

IS0020 Program Design and Software Tools Midterm, Fall, 2004

IS0020 Program Design and Software Tools Midterm, Fall, 2004 IS0020 Program Design and Software Tools Midterm, Fall, 2004 Name: Instruction There are two parts in this test. The first part contains 22 questions worth 40 points you need to get 20 right to get the

More information

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

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a. Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype

More information

Get Unique study materials from

Get Unique study materials from Downloaded from www.rejinpaul.com VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : IV Section : EEE - 1 & 2 Subject Code

More information

CGS 2405 Advanced Programming with C++ Course Justification

CGS 2405 Advanced Programming with C++ Course Justification Course Justification This course is the second C++ computer programming course in the Computer Science Associate in Arts degree program. This course is required for an Associate in Arts Computer Science

More information

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

+2 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1 Chapter -1 1. Object Oriented programming is a way of problem solving by combining data and operation 2.The group of data and operation are termed as object. 3.An object is a group of related function

More information

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

KOM3191 Object Oriented Programming Dr Muharrem Mercimek OPERATOR OVERLOADING. KOM3191 Object-Oriented Programming KOM3191 Object Oriented Programming Dr Muharrem Mercimek 1 OPERATOR OVERLOADING KOM3191 Object-Oriented Programming KOM3191 Object Oriented Programming Dr Muharrem Mercimek 2 Dynamic Memory Management

More information

G52CPP C++ Programming Lecture 13

G52CPP C++ Programming Lecture 13 G52CPP C++ Programming Lecture 13 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture Function pointers Arrays of function pointers Virtual and non-virtual functions vtable and

More information

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

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class Chapter 6 Inheritance Extending a Class Introduction; Need for Inheritance; Different form of Inheritance; Derived and Base Classes; Inheritance and Access control; Multiple Inheritance Revisited; Multilevel

More information

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

Quiz Start Time: 09:34 PM Time Left 82 sec(s) Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability

More information

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

Lecture-5. Miscellaneous topics Templates. W3101: Programming Languages C++ Ramana Isukapalli Lecture-5 Miscellaneous topics Templates W3101: Programming Languages C++ Miscellaneous topics Miscellaneous topics const member functions, const arguments Function overloading and function overriding

More information

CS201 Latest Solved MCQs

CS201 Latest Solved MCQs Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability

More information

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

Chapter 11: More About Classes and Object-Oriented Programming

Chapter 11: More About Classes and Object-Oriented Programming Chapter 11: More About Classes and Object-Oriented Programming Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Topics 11.1 The this Pointer and Constant

More information

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

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class. 1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity

More information

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

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING Unit I : OVERVIEW PART A (2 Marks) 1. Give some characteristics of procedure-oriented

More information

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

Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name: Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name: Section 1 Multiple Choice Questions (40 pts total, 2 pts each): Q1: Employee is a base class and HourlyWorker is a derived class, with

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

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

PART I.   Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++. Unit - III CHAPTER - 9 INTRODUCTION TO C++ Choose the correct answer. PART I 1. Who developed C++? (a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai 2. What was the original name

More information

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

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8

More information

Programming in C++: Assignment Week 4

Programming in C++: Assignment Week 4 Programming in C++: Assignment Week 4 Total Marks : 20 March 22, 2017 Question 1 Using friend operator function, which set of operators can be overloaded? Mark 1 a.,, , ==, = b. +, -, /, * c. =,

More information