difference between class and interface in java

Let’s learn difference between class and interface in java.

difference between class and interface in java

Here’s the difference between class and interface.

  • “class” keyword is used to create class. Whereas “interface” keyword is used to create an interface.
  • class does not support multiple inheritance whereas interface support multiple inheritance.
  • class is instantiated to create objects while an interface can’t be instantiated.
  • class do have constructors whereas interface do not have constructors.
  • class have incomplete and complete method whereas interface have only (incomplete) abstract methods.
  • class access modifiers can be private, public and protected whereas interface access modifier is “public” by default.
  • class can be inherited by another class using “extends” keyword. While interface can be inherited by class using “implements” keyword and interface can be inherited by an interface using “extends” keyword.