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
Are arrays primitive data types?
What environment variables do I need to set on my machine in order to be able to run java programs?
What is a protected void?
What is string pooling concept?
Are arrays passed by reference in java?
What is the role of garbage collector in java?
What is static keyword?
How do you reverse a list?
Define locale.
What is threaded programming and when is it used? : Java thread
Can java run on google chrome?
What is the difference between Java Program Constructor and Java Program Method, What is the purpose of Java Program constructor Please Explain it Breafily?
In how many ways we can create threads in java?
What do you mean by stack?
Name some OOPS Concepts in Java?