Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




.NET interview questions: - Mention interfaces in details with examples?

This is the basic and all time favorite .NET interview questions asked in the start or during the interview by the interviewer. So start with the definition & use an example to express the fundamental of the topic in more detail.

In real world interface allows two disparate/ different objects to communicate with each other. For instance a human is a very different object when compared to television object. But they can still use the remote control interface to communicate with each other. Same holds true for interfaces in software, it defines a communication vocabulary between objects. Interfaces have empty methods and we can not create an object of interface.

Figure: - Television interface

The other important thing is that interface brings in lot of uniformity in the project. They define common way of communication. Let’s consider a situation where you have multiple developers working on customer and supplier classes. You want that every developer should define the method name as ‘Update’ when these classes add the data to database. Developers are human’s so some would name it as update and some as add. You can tackle this situation by defining an interface with a method called as update. Now all the classes inherit from the same interface thus making update method constant through out the classes. You can also see how the client code methods are looking consistent in naming convention thus enforcing consistent communication interfaces across all classes.

Figure: - Interface fundamentals

Also see the OOPS fundamental video on polymorphism and its types as follows: -

Visit to get more stuff on .NET interview questions

Regards,

Also visit for more author’s other blogs on .NET interview questions

Share this article   |    Print    |    Article read by 2134 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles: No related article
Related Interview Questions: No related interview question