+ 15
What is the difference between abstract class and interface in java?
6 Answers
+ 3
i explained here already: https://www.sololearn.com/Discuss/363907/?ref=app
here the full explanation:
Interface:
- Contains no concrete implementation of a method
- a subclass can implement (theoretically) an infinite amount of interfaces
- Interfaces are faster than abstract classes
Abstract class:
- Can contain concrete implementation of a method
- a subclass can only implement one super-class
+ 9
very helpful Thank you
+ 6
an abstract class may have abstract and non abstract members in it. abstract classes are extended to another class to define the abstract functions.
An interface may only have abstract functions.It is implemented to a class to define the functions in the interface
+ 3
As of Java7 (we have Java 8 now), interfaces can have implemented methods. You just need to use the default keyword. They still cannot have non static variables with a starting value.
+ 2
if you think my answer was of any help, then please consider marking my answer as the best answer. thanks in advance.
0
abstract class contain abstract methods and non abstract methods and in case of interfaces they contain only abstract methods and interfaces are implemented to a class and all methods in it must be override...