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
What are synchronized blocks in java?
When throw keyword is used?
What is an eror in java?
Does treeset use compareto?
What are encapsulation, inheritance and polymorphism?
Can an anonymous class be declared as implementing an interface and extending a class in java programming?
Outline the major features of java.
Can we create an object of static class in java?
Can we execute a program without main?
Does garbage collection occur in permanent generation space in jvm?
What is the most important feature of java? What is an interface?
Can a main method be declared final?
How many bytes is a string?
Can we declare main () method as non static?
How is string immutable in java?