Difference between Abstract Class and Interface Difference between abstract class and interface ? Abstract Class:- 1) Can have abstract and non-abstract method both. 2) One class can extend at most one class. 3) can declare non abstract method and also can define body for it. Interface:- 1) can have only abstract method. 2) One class can implement multiple interfaces. 3) can't delare body to a method. Please look below example for more understanding:- package Basics ; public abstract class Animal { int head ; //no body (unimplemented function need to override in child class as a //compulsion abstract void setLegs (); //having body //may override or may not void setHead () { head =1; } } package Basics ; // can have only methods and by default all are abstract need to be override //by implementing class, unlike abstract no method can havedefinition public interface Pet { void tellWhereAreYouFr...
Data structures, Algorithms and system designs