Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C# code?
{
int i;
Console.WriteLine(“Hi”);
for (i = 1; i <= 10; i++)
Program.Main(args);
Console.ReadLine();
}

What will be the output of the following C# code?
{
int i;
Console.WriteLine(“Hi”);
for (i = 1; i <= 10; i++)
Program.Main(args);
Console.ReadLine();
}
a) Prints ‘Hi’ for one time
b) Prints ‘Hi’ for infinite times
c) Stack overflow exception Condition generated
d) None of the mentioned

Answer: c
Explanation: Occurrence of ‘main()’ condition after for loop.
Output: Hi
Hi
.
.
stack overflow exception.

Join The Discussion