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)
{
int movie = 1;
switch (movie << 2 + movie)
{
default:
Console.WriteLine(“3 Idiots”);
break;
case 4:
Console.WriteLine(“Ghazini”);
break;
case 5:
Console.WriteLine(“Krishh”);
break;
case 8:
Console.WriteLine(“Race”);
break;
}
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
int movie = 1;
switch (movie << 2 + movie)
{
default:
Console.WriteLine(“3 Idiots”);
break;
case 4:
Console.WriteLine(“Ghazini”);
break;
case 5:
Console.WriteLine(“Krishh”);
break;
case 8:
Console.WriteLine(“Race”);
break;
}
Console.ReadLine();
}
a) 3 Idiots
b) Ghazini
c) Race
d) Krishh

Answer: c
Explanation: We can put ‘default’ case in any order and hence write cases in any order.
Output: Race.

Join The Discussion