Question 1: What will be the output of the following program?
public class Program
{
public static void Main()
{
int?[] arr = new int?[5];
Console.WriteLine(arr[0]);
}
}
Question 2: What will be the output of the following program?
public static void Main()
{
var i=10, j=2, k=3;
Console.WriteLine(k=i*j);
}
Question 3: What is the difference between var and dynamic type?
Question 4: If you want to hold a positive integer value up to 250. Which of the following data type will you use for a variable?
Question 5: What will be the output ofConsole.WriteLine(Convert.ToInt32('A'));
?
Question 6: What will be the output of the following code?
IList nums = null;
Console.Write(nums?[0]);
Question 7: Which of the following keyword is used to reference two assemblies with the same fully qualified type names?
Question 8: Which of the following statements is TRUE?
Question 9: What will be the output of the following program?
public static void Main(string[] args)
{
test();
}
void test(){
Console.Write("test()");
}
Question 10: What will be the output of the following program?
class Program
{
static void Main()
{
Person p = new Person() {
Id = 1
};
Console.Write(p.ToString());
}
}
class Person
{
public int Id;
public override string ToString() => this.Id.ToString();
}
Question 11: What will be the output of the following program?
public static void Main()
{
while (DoSomething());
}
static bool DoSomething() {
Console.Write("working");
return false;
}
Question 12: An enum cannot be declared inside a method.
Question 13: Which of the following statements are TRUE?
Question 14: What will be the output of the following program?
public static void Main(string[] args)
{
Point p;
Console.Write( p.x);
}
struct Point
{
public int x;
}
Question 15: What will be the output of the following program?
public class Program
{
public static void Main()
{
int i = 3;
int[] arr = new int[i] {10, 20, 30};
Console.Write(arr[0]);
}
}
Question 16: What will be the output of the following program?
public static void Main()
{
int[] arr = {1, 2, 3, 4, 5};
try
{
Console.Write(arr[10]);
}
catch(Exception ex){
Console.WriteLine("Error occurred!");
}
finally
{
Console.WriteLine("Executing finally block");
}
Console.WriteLine("Executing remaining program");
}
Question 17: Which of the following statement is TRUE?
Question 18: How would you declare an event for the following delegate?
public delegate void ClickHandler();
Question 19: Which of the following keyword is used to raise an exception manually?
Question 20: How to pass a function as a parameter in C#?