Professional Documents
Culture Documents
SUBJECT:-COMPUTER SCIENCE
CHAPTER-12
INHERITANCE AND POLYMORPHISM
Book name: -UNDERSTANDING isc
computer science by APC
(COPY WORK)
PAGES:-(520-523)
EXERCISE 3:-ANSWER THE FOLLOWING
(PAGE 521)
Q1. What do you understand by inheritance?
Ans. The process by which one class acquires the properties of another class.
Q2. Explain ‘Polymorphism’ with a suitable example.
Ans. The process of declaring functions with the same name but for different purposes.
EXAMPLE:- void area(int l,int b)
void area(int r)
Q3. What do you mean by a base class?
Ans. A class which is getting inherited is known as base class.
Q4.Differentiate between a base class and derived class.
Ans. BASE CLASS:- A class which is getting inherited.
DERIVED CLASS:- A class which inherits the another class.
Q5.What do you mean by function overloading?
Ans. A process of defining functions with the same function names but with different
number and types of parameters.
Q6. What is polymorphism?
Ans. The process of declaring functions with the same name but for different purposes.
Q8. What is the need of polymorphism in Java
programming?
Ans. Polymorphism enables one entity to be used as
a general category for different types of actions. The
specific action is determined by the exact nature of
the situation.
Q9. Define the term ‘Function Signature’.
A function's signature includes the function's name
and the number, order and type of its
formal parameters.
Q10. What is the significance of using protected
declaration during inheritance? Show with the help
of an example.
Sometimes it may be necessary for a subclass to access a private member of a superclass.
If you make a private member public, then anyone can access that member. So, if a
member of a superclass needs to be (directly) accessed in a subclass and yet still prevent
its direct access outside the class, you must declare that member protected.
For example, let's imagine a series of classes to describe two kinds of shapes: rectangles
and triangles.
These two shapes have certain common properties height and a width (or base).