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
Advertisements

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

w

Connecting to %s