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
Answer Posted / 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 View All Answers
What is deadly diamond problem?
What is difference between assembly and dll?
What is equal c#?
What is the difference between parse and tryparse in c#?
What will a loop recorder show?
What is serialization in unity?
How many types of serialization are there in c#?
Write a program in C# for checking a given number is PRIME or not.
What is the advantage of constructor in c#?
How can you prevent escaping on backslashes in C# with string definitions?
How to parse a date time string?
What is the correct way of declaring an xml namespace?
How do you prevent a class from being inherited in c#?
What is the difference between field and variable in c#?
What is the difference between int and int in c#?