What is the difference between abstract class and interface in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 15

What is the difference between abstract class and interface in java?

2nd Mar 2017, 11:13 PM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
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
25th Jun 2017, 1:21 PM
Thanh Le
Thanh Le - avatar
+ 9
very helpful Thank you
26th Jun 2017, 1:06 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
+ 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
3rd Mar 2017, 12:10 AM
Jishnu Jayarajan
+ 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.
4th Mar 2017, 5:18 AM
1of3
1of3 - avatar
+ 2
if you think my answer was of any help, then please consider marking my answer as the best answer. thanks in advance.
26th Jun 2017, 8:42 AM
Thanh Le
Thanh Le - avatar
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...
3rd Mar 2017, 1:16 AM
Ramachandra Reddy
Ramachandra Reddy - avatar