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 Is Composition?

574


What is the difference between abstract class and interface1? What is an interface?

551


What is bytecode in java ?

600


how can you catch multiple exceptions in java?

538


What are reference variables in java?

587






What do you mean by exception handling in Java?

653


How many decimal digits is 64 bit?

524


How many characters is 2 bytes?

522


What are advantages of exception handling in java?

576


What is a static class in java?

548


What is this keyword used for?

678


Why hashcode is used in java?

493


What is pass by value?

506


What is thread start?

512


Is it possible to instantiate the abstract class?

534