Answer Posted / mukthiyar
Inheritance is a Reusable of the existing code.
There are two types of Inheritance implementation
Inheritance and interface Inheritance.
Implementation inheritance promotes reusability but improper
use of class inheritance can cause programming nightmares by
breaking encapsulation and making future changes a problem.
With implementation inheritance, the subclass becomes
tightly coupled with the superclass. This will make the
design fragile because if you want to change the superclass,
you must know all the details of the subclasses to avoid
breaking them. So when using implementation inheritance,
make sure that the subclasses depend only on the behavior of
the superclass, not on
the actual implementation.
Interface inheritance promotes the design concept of program
to interfaces not to implementations. This also reduces the
coupling or implementation dependencies between systems. In
Java, you can implement any number of interfaces. This is
more flexible than implementation inheritance because it
won’t lock you into
specific implementations which make subclasses difficult to
maintain. So care should be taken not to break the
implementing classes by modifying the interfaces.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a boolean in java?
How do you override a method?
What is a java predicate?
When parseint method can be used?
What are register variables what are the advantages?
What is difference between c++ and java ?
What is exception hierarchy in java?
Can a private method of a superclass be declared within a subclass?
What are daemon Threads in java?
What is generics in java interview questions?
What are the advantages of inner classes?
What is return type in java?
What are the restriction imposed on a static method or a static block of code?
Explain some best practices you would apply while using collection in java?
How can we achieve thread safety in java?