275 points
10 4 4

In programming language, there are three type of models, interface, abstract class and concrete class. If you have nothing about implementation just only have the declarations, then it will considered as interface whereas if you have all implementation of the related functionality then it will be considered as concrete class.

Difference between a class and an interface

  • A class should have implementation for so me of its members (methods, properties, indexer and events), but an interface can't have implementation for any of its members.
  • A class can have fields where as interfaces cannot have fields.
  • A class can inherit from another class (either concrete or abstract) or other interfaces, whereas an interface can extends from another interface only and cannot extends from an abstract class.
  • A class can implements from multiple inter faces at the same time, but a class can not inherit from multiple classes at the same time.
  • The class members can have access modifiers, but interface members doesn’t required access modifiers because all of it’s members are public.
  • A class used in purpose of implementation where as interfaces are used in purpose of dependency injection.
  • The 'interface' keyword used for create an interface where 'class' keyword is used to create a class.
  • Interface required to use implements/extends keyword or the extends operator ':’ based on language definition to inherit in concrete classes.
  • In example here the Payment is an interface where as PayPal is is a class.
    public interface Payment
        void makePayment();//by default it is a abstract method
    public class PayPal implements Payment
        public void makePayment()
            //some logic for PayPal payment



I have learned new things today. Keep posting :)
This is something I was looking for quite some time. Thanks for posting this.
Nice explanation... Keep sharing more..

Hey Mhfaisal! If you are new to programming, the class and interface can be really difficult. Most students get scared of the interface and stop learning programming. You have explained it very well. Waiting for more articles like this.  I will stay. Thank you very much.yes

More Posts

What is the difference between id and class in css Sanjana Sagar - May 22
What is difference between abstract class and interface in java kesav.eee - Jun 1
Difference between abstract and interface in java Sanjana Sagar - May 28
Difference between abstract and interface in java Sanjana Sagar - May 28
What is difference between interface and abstract classes? Sumran Ali - May 9
Java error: class, interface, or enum expected Hasnain_khan - Oct 13, 2020
Difference between class method and static method in python Tania - Aug 9
Difference between inner class and nested class Sanjana Sagar - May 29
Difference between class and id attribute in html Sanjana Sagar - May 28
Difference between class and method in java Sanjana Sagar - May 20