Shekhar Kumar
When do we use interface and when do we use abstract class?
By Shekhar Kumar in C# on Nov 26 2019
  • Nisha Regil
    Sep, 2020 9

    InterfaceIt is used to achieve total abstraction. Since java does not support multiple inheritance in case of class, but by using interface it can achieve multiple inheritance . It is also used to achieve loose coupling. Interfaces are used to implement abstraction.Abstract The purpose of an abstract class is to define some common behavior that can be inherited by multiple subclasses, without implementing the entire class.An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to define functionality, not implement it. And whereas a class can extend only one abstract class, it can take advantage of multiple interfaces

    • 3
  • Swapnil
    Jul, 2020 4

    Basically interface and abstract class both used for abstration.

    abstract class

    1. Acstract class can not be initiated .
      When you want to default behaviour to method then in abstract class we can do but in interface not possible
      For example we want to provide basic calculation to implementing class then we can do in abstract class.

    • 2


Most Popular Job Functions


MOST LIKED QUESTIONS