can any one tell me when do u go for inheritance and
polymorphism
Answer Posted / 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 |
Post New Answer View All Answers
What is the inheritance?
How does finally block differ from finalize() method?
Explain JMS in detail.
what do you mean by classloader in java?
Why set do not allow duplicates in java?
What do you mean by mnemonics?
What is hashmap in java?
What are parameters in a method?
What is the use of a conditional inclusion statement in Java ?
Can you give few examples of final classes defined in java api?
What is the difference between private & public & friendly classes?
What are the two ways to create a thread?
What is unicode datatype?
What is an exception? difference between Checked and Unchecked exception in Java
What does bitwise or mean?