Vidyalelo
C# Programming · Q189

Classes and Objects in C Sharp

Programming · C# Programming · question 189

Q189

What will be the output of the following C# code? class maths public maths() Console.WriteLine("constructor 1 :"); public maths(int x) int p = 2; int u; u = p + x; Console.WriteLine("constructor 2: " +u); class Program static void Main(string[] args) maths k = new maths(4); maths t = new maths(); Console.ReadLine();

A.
constructor 1:
constructor 2: 6
B.
constructor 2: 6
constructor 2: 6
C.
constructor 2: 6
constructor 1:
Answer
D.
none of the mentioned

Answer: Option C

Solution

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