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
Can you instantiate the math class?
What exactly is a .class file?
How can you make a class serializable in java?
write a program that list all permutations of ABCDEF in which A appears before B?
Can bool be null?
How can I debug the Java security exceptions and AccessControlExceptions?
What is a war file?
What is parameter example?
What about anonymous inner classes in java?
What is the final keyword denotes?
What is JDBC Driver interface?How can you retrieve data from the ResultSet
what is singleton in java?
Can a class extends itself in java?
Is main a keyword in java?
What are the advantages of java?