what is the need of using interface in program
ex:if we have a program like this
interface1()
{
void method1();
void method();
}
class a1 : interface1
{
a1 b = new b();
b.method1();
b.method2();
}
so without using interface also we can achieve this then
wat is the need to use the interface?
plz give me the answer





what is the need of using interface in program ex:if we have a program like this interface1() { ..

Answer / saranya

In a program if multiple classes which has the some common
methods are used,then in that case we will use interfaces.
With the classes you wont left a method without definition
unless that is abstract.Interfaces will help us to provide
different implementations according to user needs.In
interface by default all methods are PUBLIC.But in class by
default it is private.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Sharp Interview Questions

which datatype i have to use we i need dynamic size.for eg. empname .in first row it have only five chars.but next row it have 100 chars.

3 Answers  


Can we inherit private class in c#?

0 Answers  


What is a di class?

0 Answers  


what is used ref keyword in c#,and how we used it?

2 Answers  


Can I do things in il that I can't do in c#?

0 Answers  






Which controls do not have events?

0 Answers  


What is the purpose of namespace in c#?

0 Answers  


What is the use of generics in c#?

0 Answers  


What is difference between property and variable in c#?

0 Answers  


What is the purpose of ienumerable in c#?

0 Answers  


Hello Friends..am Mohammed riyash..final year BCA in Jamal Mohamed College 2009. Trichy. My doubt is while connecting SQL2005 Built in Database withing the Visual Studio 2005 Framework.. I am getting the error.. That " An Error occurred and it may be due to , under the default settings of the Server, the connection cannot be established.." But the code works in MS Access for me.. Both in VB.Net and C#.Net am getting the same error.. Any genius please Message me to 9994558822 or mail me.. riyash.ips@gmail.com

3 Answers  


Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?

0 Answers  


Categories