Books MVC ASP.NET C# SQL Server WCF Written Test HR Round Subscribe C# Videos C# Programs Support Us

What are the advantages of using interfaces



This is the most commonly asked interview question. This interview question is being asked in almost all the dot net interviews. It is very important that we understand all the concepts of interfaces and abstract classes.

Interfaces are very powerful. If properly used, interfaces provide all the advantages as listed below.

1. Interfaces allow us to implement polymorphic behaviour. Ofcourse, abstract classes can also be used to implement polymorphic behaviour.

2. Interfaces allow us to develop very loosely coupled systems.
3. Interfaces enable mocking for better unit testing.

4. Interfaces enables us to implement multiple class inheritance in C#.

5. Interfaces are great for implementing Inverson of Control or Dependancy Injection.

6. Interfaces enable parallel application development.

If you can think of any other advantages of using interfaces, or if you can add more explanation, please feel free to do so using the form below.

For basic interview questions on interfaces, you can read this article.

8 comments:

  1. When you don't want a massive hierarchical type framework we prefer interface

    ReplyDelete
  2. So would you say you could declare an interface and any class implementing that interface will be type safe?

    ReplyDelete
  3. I know interface can be passed as parameter .Is it possible in abstract class?

    ReplyDelete
  4. explain this
    1.Inverson of Control or Dependancy Injection.
    2.parallel appliction development....

    ReplyDelete
  5. we are using interfaces in distributed architecture,, because for giving the reference to the client we use interfaces, which will provide the methods or functions signature .
    and one more thing when we deploy any application on client system then we have three things to deploy i.e
    1. UI (exe file) that is nothing the application
    2.config file
    3.interface's .dll files

    ReplyDelete
  6. You are just great trainer and tutor, I really like your videos because they do save a lot of time and effort to learn c#. I believe since I graduated in 2004 that I will not understand OOP in my whole life, but it seems that in your lessons you are making things easier to understand.

    Regards,,
    Yusuf

    ReplyDelete
  7. I truly agree with you Yusuf, that Venkat is great trainer. His videos are really helpful to understand concepts. At my home even my 4 year old son knows that I watch Venkat's video and he do ask me daily "R u done with Venkat Videos". Thanks Venkat for all your effort.

    Regards,
    Sangeeta

    ReplyDelete

If you are aware of any other C# questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us