Question 1: What will be the output of the following program?
public static void Main(string[] args)
{
int a = 1, b = 2, c = 3;
Console.Write(a+b*c);
Console.Write (a+(b*c));
Console.Write ((a*b)+(b*c));
Console.Write ((a*b)+(b*c)-c);
}
Question 2: What will be the output of the following program?
public static void Main(string[] args)
{
int x = 2, y = 6, z;
z= x * ( y + x) / (y - x) + 10;
Console.Write(z);
}
Question 3: What will be the output of the following program?
public static void Main(string[] args)
{
int a = 2;
Console.Write( ++a);
Console.Write(a++);
Console.Write( a);
}
Question 4: What will be the output of the following program?
class Program
{
static void Main()
{
Person p = null;
var name = p?.FirstName ?? "Unknown" + p?.LastName ;
Console.Write(name);
}
}
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
Question 5: What will be the output of the following code?
IList numbers = null;
Console.Write(numbers?[0]);