Abstract class vs Interface

Let first know difference between an Abstract class and Interface.

Interface 
1. A class can implement  n number of  interface, because it support multiple interface.
2. An interface can only have all abstract method.
3.We can declare properties but we cannot use variable.

Abstract

1. In an abstract class  the Sub class can use only one abstract class.

ex:- 
       using System;
using System.Text;


namespace Test_Application
{
    abstract class Vehicle
    {
        public void Car(){  -----  }            
    }
    abstract class flight
    {
        public void jet() {  ----- }
    }
    class Program : Vehicle, flight //  Multiple Abstract class not possible , compilation error.
    {      
        public static void Main(string[] args)   {    ----     }        
    }       
 }   

2. An abstract class can have concrete class(non abstract class) and abstract class.
3. We can use any variables.




Share this

Previous
Next Post »