+ 7

What is the difference between abstract and interface in Java ?

30th Apr 2019, 1:49 AM
suvam prasad
suvam prasad - avatar
6 Respostas
+ 5
Basically, in Java you can implement as many interfaces as you'd like. On the other hand a class can only extend one abstract class.
1st May 2019, 8:21 PM
hamza belmellouki
hamza belmellouki - avatar
30th Apr 2019, 7:46 PM
Denise Roßberg
Denise Roßberg - avatar
+ 5
interface is a specific class which is fully abstract & u don't need to use the keyword abstract for every single method and property inside an interface.
1st May 2019, 8:05 PM
Abdol Hashimi
Abdol Hashimi - avatar
+ 4
Abstract Class: *Abstract classes have a default constructor and it is called whenever the concrete subclass is instantiated. *Contains Abstract methods as well as Non-Abstract methods. *The class which extends the Abstract class shouldn’t require implementing all the methods, only Abstract methods need to be implemented in the concrete sub-class. *Abstract Class contains instance variables. Interface: *Doesn’t have any constructor and couldn’t be instantiated. *Abstract method alone should be declared. *Classes which implement the interface should provide the implementation for all the methods. *The interface contains only constants.
14th May 2019, 2:01 PM
Tharani Dayadhi Karunathialaka
Tharani Dayadhi Karunathialaka - avatar
+ 4
One of the differences between them: Abstract class can provide method body while interface cannot https://www.sololearn.com/post/1101682/?ref=app
24th May 2021, 8:12 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar