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?
static void Main(string[] args)
{
m();
Console.ReadLine();
}
static void m()
{
Console.WriteLine(“HI”);
m();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
m();
Console.ReadLine();
}
static void m()
{
Console.WriteLine(“HI”);
m();
}
a) HI HI HI
b) HI
c) Stack overflow exception
d) Compile time error

Answer: c
Explanation: Control of statement when enters for once in m() does not go out, then it executes again and again inside the block until stack overflow exception occurs.

Join The Discussion