What will be the output of the following C# code?
interface i1
{
void fun();
}
interface i2
{
void fun();
}
public class maths :i1, i2
{
void i1.fun()
{
Console.WriteLine("i1.fun");
}
void i2.fun()
{
Console.WriteLine("i2.fun");
}
}
class Program
{
static void Main(string[] args)
{
Sample obj = new Sample();
i1 i = (i1) obj;
i.fun();
i2 ii = (i2) obj;
ii.fun();
}
}
interface i1
{
void fun();
}
interface i2
{
void fun();
}
public class maths :i1, i2
{
void i1.fun()
{
Console.WriteLine("i1.fun");
}
void i2.fun()
{
Console.WriteLine("i2.fun");
}
}
class Program
{
static void Main(string[] args)
{
Sample obj = new Sample();
i1 i = (i1) obj;
i.fun();
i2 ii = (i2) obj;
ii.fun();
}
}A. i1.fun
B. i2.fun
i1.fun
C. 0
D. i1.fun
i2.fun
Answer: Option D
Related Questions on Classes and Objects in C Sharp
A. A blueprint for creating objects
B. A method in C#
C. A variable in C#
D. A data type in C#
A. A method in C#
B. A variable in C#
C. An instance of a class
D. A data type in C#
A. public
B. private
C. protected
D. internal

Join The Discussion