Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
109 views

Difference Between Abstract Class and Interface

An abstract class can contain both abstract and non-abstract methods, while an interface can only contain abstract methods. An abstract class can implement an interface but an interface cannot implement an abstract class. An abstract class can be extended by another class using the "extends" keyword, while an interface is implemented by a class using the "implements" keyword.

Uploaded by

Manish WsCube
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views

Difference Between Abstract Class and Interface

An abstract class can contain both abstract and non-abstract methods, while an interface can only contain abstract methods. An abstract class can implement an interface but an interface cannot implement an abstract class. An abstract class can be extended by another class using the "extends" keyword, while an interface is implemented by a class using the "implements" keyword.

Uploaded by

Manish WsCube
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

www.wscubetech.

com
info@wscubetech.com

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
info@wscubetech.com

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

You might also like