+ 2
What is difference between abstract and interface
2 Réponses
+ 6
Think of interface as a class with abstract methods only. Abstract means you declare it but don't implement it. In an interface it is true about every method.
Later when you are good in Java you will see that it the life is a bit more difficult.
+ 1
Abstract class and interface both are used to achieve abstraction where we can declare the abstract methods. Abstract class and interface both can't be instantiated.
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The basic difference between them----->>>>
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(1) Abstract class doesn't support multiple inheritance &>😎<& Interface supports multiple inheritance.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(2) The abstract keyword is used to declare abstract class.&<😎>The interface keyword is used to declare interface.
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(3) Abstract class can have final, non-final, static and non-static variables.&<😎>Interface has only static and final variables.
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||