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
Explain about varargs in java?
Why is java called java?
What are the types of methods in java?
Explain about exception propagation?
What is java and its types?
What is garbage collection? What is the process that is responsible for doing that in java?
What is a dynamic array java?
Print Vertical traversal of a Binary Tree.
What are "class access modifiers" in Java?
What is exception hierarchy in java?
Which number is denoted by leading zero in java?
How do we access static members in java?
What is the difference between private & public & friendly classes?
What is difference between string and stringbuffer?
What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?