CBSE Computer Science - Revision Tour(Solved) CBSE Guess > eBooks > Class XII > CBSE Computer Science Object oriented programing Solved Revision Tour By Mr. Ravi Kiran COMPUTER SCIENCE OBJECT ORIENTED PROGEAMING 2004 1.a) What is polymorphism? Give an example in C ++ to show its implementation in C++. Ans:Polymorphism is the attribute that allows one interface to be used with different situation.C++ implements polymorphism through virtual functions, through overloaded functions and overloaded operators. A virtual function is used to specify the interface in abstract class, but its implementation details are made available by the concrete class(es). An overloaded function refers to a function having (one name and) more than one distinct meanings. Similarly, when two or more distinct meanings are defined for an operator, it is said to be an ‘overloaded operator’. It is the compiler’s job to select the specific action as it applies to each situation. Eg: The program in the next answer. 2003: 2.a) What do you understand by function overloading? Give an example illustrating its use in a c++ program. Ans: A function name having several definitions that are differentiable by the number or types of their arguments, is known as an overloaded function and this process is known as function overloading. Function overloading not only implements polymorphism but also reduces number of comparisons in a program and thereby makes the program run faster. Example: program illustrating function overloading: //Program to find out area of a circle or area
of rectangle using //function overloading.
2000: 1.a) Illustrate the concept of function overloading with the help of an example. 1 Ans: The above answer.
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com ) |