www.wscubetech.
com
[email protected]
Difference between abstract
class and interface
1st Floor, Laxmi Tower, Bhaskar Circle, Ratanada, Jodhpur.
Development – Training - Placement - Outsourcing
abstract class v/s interface
Abstract class Interface
1) Abstract class can have abstract and non- Interface can have only abstract methods. Since
abstract methods. Java 8, it can have default and static
methods also.
2) Abstract class doesn't support multiple Interface supports multiple inheritance.
inheritance.
3) Abstract class can have final, non-final, static Interface has only static and final variables.
and non-static variables.
4) Abstract class can provide the implementation Interface can't provide the implementation of
of interface. abstract class.
5) The abstract keyword is used to declare The interface keyword is used to declare interface.
abstract class.
6) An abstract class can extend another Java class An interface can extend another Java interface
and implement multiple Java interfaces. only.
2
www.wscubetech.com
Continue…
7) An abstract class can be extended using An interface can be implemented using
keyword "extends". keyword "implements".
8) A Java abstract class can have class Members of a Java interface are public by
members like private, protected, etc. default.
9)Example: Example:
public abstract class Shape{ public interface Drawable{
public abstract void draw(); void draw();
} }
3
www.wscubetech.com
www.wscubetech.com
[email protected]
Thank You
https://www.facebook.com/wscubetech.india https://www.linkedin.com/company/wscube-tech
https://plus.google.com/+wscubetechjodhpur https://www.youtube.com/c/wscubetechjodhpur
https://twitter.com/wscube
1st Floor, Laxmi Tower, Bhaskar Circle, Ratanada, Jodhpur.
Development – Training - Placement - Outsourcing