can any one tell me when do u go for inheritance and
polymorphism
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / krish
Inheritance:Your are in a situation where you have to the
properties of a whole class repeatedly then you can go for
inheritance.
Note:Final class can't be inherited.
Polymorphism:When you are in a situation where you need to
use a method repeatedly then you can go for polymorphism.
Eg:
consider this method
add(int i,int j) and add(String s1,String s2)
the former will add two integers and later will concatenate
two strings but both using the same method name.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kishor kommulas
Inheritance:::
If you want to make use of the functionality of the method,
which is already there then you can go for the inheritance.
Polymorphism::::
If you want to use the same method name for different
method,then you can go for Polymorphism.
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain inner classes ?
How does arraylist work in java?
Is it possible to override the main method?
What defines function?
What is clipping and repainting and what is the relation between them?
What is mnemonic in assembly language?
What are the differences between path and classpath variables?
What is the mapping mechanism used by java to identify IDL language?
Hai friends I am MCA 2006 passout. Spend time in 1 yr for teacing and 5 months in small s/w firm. worked in 4 or 5 months in few places. Presently I am writing bank exams. I want to get back to IT sector. Are there any possibilities. any growth prospects?. I am having some knowledge in core and advanced java. I am so desperate. Any suggestions thanks in advance. u can write to my mail mahidestiny@gmail.com
What is java developer skills?
How to change the priority of thread or how to set priority of thread?
What is the difference between declaration and definition in java?