You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
access modifiers for abstract methods can be -> default, public, protected EXCEPT private:
Non-abstract
access modifiers for non-abstract methods can be -> default, public, private, protected:
Fields in abstract class:
Non-static and non-final
Final
Static
Static final
Constructors in abstract class:
Constructor in abstract class
Usage of constructor in non-abstract class
Abstract class vs interface
Methods
abstract class: can be abstract and nont abstract
interface: can be abstract, default, static
Access modifiers
abstract class: methods can have private, public, default and protected
interface: methods are by default public abstract only
Variables
abstract class: can be non-static and non-final
interface: by default are public static final
Constructor
abstract class: can have constructor
interface: cannot have constructor
Multiple inheritance
abstract class: can extend at most one class and implement one or more interfaces
interface: can only extend one or more interfaces
Extends/Implements
abstract class: abstract classes are extended by the sub-class. Sub-classes need to provide implementation for all abstract methods or class shall be declared as abstract as well
interface: interface is implemented by a class and the implementing class needs to provide implementation for all methods. If class does not implement all methods class shall be declared as abstract