Posted in Core Java

Java – Abstract class vs Interface

 

Abstract class

Interface

Have abstract & non-abstract methods Only abstract methods
Not support multiple inheritance Supports multiple inheritance
Can have final/non-final/statis/non-static variables Only final & static variables
Can have:

·         static methods

·         main method

·         constructor

Cannot have

 

 

 

Can provide implementation of interface Cannot provide implementation of abstract class
When we want to add new methods When we want to have multiple inheritance
We extend it We implement it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s