what is difference between abstract and interface?
can i give real time example for the two topics?
Answer Posted / lakshmi
Interface has no implementation, but they have to be
implemented.
Abstract class’s methods can have implementations and they
have to be extended.
Interfaces can only have method declaration (implicitly
public and abstract) and fields (implicitly public static)
Abstract class’s methods can’t have implementation only
when declared abstract.
Interface can inherit more than one interfaces
Abstract class can implement more than one interfaces, but
can inherit only one class
Abstract class must override all abstract method and may
override virtual methods
Interface can be used when the implementation is changing
Abstract class can be used to provide some default behavior
for a base class.
Interface makes implementation interchangeable
Interface increase security by hiding the implementation
Abstract class can be used when implementing framework
Abstract classes are an excellent way to create planned
inheritance hierarchies and also to use as non-leaf classes
in class hierarchies.
Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
What do you meant by active and passive objects?
How will you load a specific locale?
explain the difference between jdk and jvm?
What does substring mean?
What is the lifetime and scope of a variable?
Explain the differences between static and dynamic variables?
Is java a digit method?
What is a map in java?
What are the three types of design patterns?
What is the program development process?
What is the requirement of thread in java?
State some advantages of java?
What do you mean by flow of struts?
What is parsing in grammar?
What is a static class in java?