.NET interview questions: -Can you explain interfaces in details with examples?
- By Shiv Prasad Koirala in .Net
- Jan 28th, 2012
- 11518
- 0
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 important .NET interview questions Regards,
Also visit for more author's other blogs on Most asked .NET interview questions
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more