Answer Posted / pari
Minimize the amount of duplicate code in an application
If duplicate code (variable and methods) exists in two related classes, we can refactored that hierarchy by moving that common code up to the common superclass.
Better organization of code
Moving of common code to superclass results in better organization of code.
Code more flexible change
Inheritance can also make application code more flexible to change because classes that inherit from a common superclass can be used interchangeably. If the return type of a method is superclass.
Where to use inheritance:
Before using inheritance first compare the relationship for the two classes. Use inheritance only if there is a parent child relationship is there.
A way to test the relationship is to ask a "is-a" question.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Write a program in java to establish a connection between client and server?
Difference between arraylist and vector.
What is logical variable?
What are access specifiers in java ?
What is difference between public static and void?
How do you get the length of a string in java?
Mention some interfaces implemented by linked list in java.
Can we declare an array without size in java?
What is the association?
What do you mean by boolean?
Differences between C and Java?
What is java string pool?
What is the difference between sleep and wait in java?
What are java packages? What's the significance of packages?
How will you add panel to a frame?