Vidyalelo
C# Programming · Q70

Classes and Objects in C Sharp

Programming · C# Programming · question 70

Q70

What will be the output of the following C# code? class overload public int x; int y; public int add(int a) x = a + 1; return x; public int add(int a, int b) x = a + 2; return x; class Program static void Main(string[] args) overload obj = new overload(); overload obj1 = new overload(); int a = 0; obj.add(6); obj1.add(6, 2); Console.WriteLine(obj.x); Console.WriteLine(obj1.x); Console.ReadLine();

A.
8
8
B.
0
2
C.
8
10
D.
7
8
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board