can any one tell me when do u go for inheritance and
polymorphism

Answer Posted / ganesh

Inheritance :

If you want to reuse the existing class
characteristics(methods,variables ..) then you will use
inheritance ..


Polymorphism :

If you want a method to respond based on our requirement
then we will use polymorphism ..for example like swapping
two variables is same for all types but if write program
means for different types(int,double,char..) u need to write
different methods but under a common method name..

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the important features of Java 10 release?

750


What is the importance of finally block in exception handling?

781


Is set sorted in java?

702


How to find the index of the largest number in an arraylist java?

723


What are benefits of java?

800


Explain the private field modifier?

843


What about instanceof operator in java?

792


What is the basic concept of java?

772


Explain the access modifiers for a class, method and variables?

892


What is method reference?

722


What is the primary benefit of encapsulation?

770


Can static method access instance variables ?

834


What is the generic function?

729


How garbage collection is done in java?

777


What does the “static” keyword mean? Can you override private or static method in java?

820