What will be the output of the following C# code?
interface calc
{
void cal(int i);
}
public class maths :calc
{
public int x;
public void cal(int i)
{
x = i * i;
}
}
class Program
{
public static void Main(string[] args)
{
display arr = new display();
arr.x = 0;
arr.cal(2);
Console.WriteLine(arr.x);
Console.ReadLine();
}
}
interface calc
{
void cal(int i);
}
public class maths :calc
{
public int x;
public void cal(int i)
{
x = i * i;
}
}
class Program
{
public static void Main(string[] args)
{
display arr = new display();
arr.x = 0;
arr.cal(2);
Console.WriteLine(arr.x);
Console.ReadLine();
}
}A. 0
B. 2
C. 4
D. None of the mentioned
Answer: Option C
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