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 parsing a string?
What environment variables are required to be set on a machine in order to run Java programs?
What happens if an exception is not handled in a program?
What is size of int in java?
What are access specifiers in java ?
What is jvm? Why is java called the platform independent programming language?
What is a nonetype?
Why java is used everywhere?
How hashmap works in java?
What is a qualifier in a sentence?
When will you define a method as static in Java?
Explain about abstract classes in java?
Describe how to implement singleton design pattern in struts.
What is stream api in java8?
What are identifiers in java?