+ 2
what is the difference between abstract classes and interface?
7 Respuestas
+ 4
wrong, zen. you can have abstract class without abstract method. and in jdk 1.8 we can have concrete methods in interface.
+ 3
An abstract class must have at least one methode which is not implemented and which Will bé overide by the sub-class,so here were are in inheritance.But in an interface all méthod aren't implemented,so the role of the interface is to specify a public API,and all of the class which Will implement the interface must overide all methodes
+ 2
An abstract class has at least one abstract method.
An interface has only abstract methods.
+ 1
Nick , you're quite right about having an abstract class without defining abstract methods. My question is why would you declare a class as abstract in the first place without having to create a minimum of one abstract method? . Remember the main reason why we make classes as abstract is to allow any component that inherits it provide functionality to that specific abstract method.
+ 1
we need to declare abstract keyword for class but dont need to do for an interface
0
In interface all the methods are abstract method whereas in the abstract class may or may not have the abstract method
- 1
interfaces do not have an implementation, but rather provide you with a contract you must adhere to.