Sunday 9 August 2015

What is an Interface in .net

     Interface was also a type supported in OOP's. Which can contain only Abstract Members in it.
Interface are used in two cases :

  • They are used in the development of distributed application.
  • They can be used for implementing multiple inheritance . Because multiple inheritance is supported through interface.
                 A class can have only one class has it's immediate parent class but the same class can inherite from multiple interfaces at a time
  • Inheritance can be categorized into implementation inheritance and interface inheritance .  If a class is inheriting from class we call it as implementation inheritance. this is always single both java and .Net languages.
  • If a  class is inheriting from a interface we can it as interface inheritance . these was multiple in both java and .Net languages.
 Syntax :
          [<Modifiers>] interface <Name>
        {
          -- Abstract member declarations
       }
  1. An interface cannot contain any variable declaration in it.
  2. The default scope for member of an interface is public.
  3. members of an interface are by default abstract. No need to use abstract modifiers. While declaring as well as no need to use ovverride modifier while implementing.
  4. A class can inherite from either a class or interface. In the same way an interface can inherite from another interface but not a class.
      

No comments:

Post a Comment