0
Interfaces are classes that need implementation (the methods have no code inside). To declare one use the interface keyword. To implement an interface use the implements keyword the same way you would use the extends but you can implement multiple interfaces. Interfaces can extend other interfaces. Also interfaces obviously cannot be instanced. Example: interface Animal { public void makeSound(); public void eat(); } Other file... public class Dog implements Animal { public void makeSound() { System.out.println("Woof woof!"); } public void eat() { System.out.println("Yum yum!"); } } On the other hand an abstract function can have abstract methods which the classes that will extend from have to implement either by the class itself or it's children. Abstract classes can have normal methods, interfaces cannot. Both abstract classes & methods have the abstract keyword in front of them. You can google more differences.
26th Mar 2018, 6:46 PM
TurtleShell
TurtleShell - avatar