Question 1: What will be the output of the following program?
public static void Main()
{
int i;
Console.WriteLine(i);
}
Question 2: What will be the output of the following code?
int i = 5, j;
Console.WriteLine(j=i*2);
Question 3: What will be the output of the following program?
public static void Main()
{
int k;
display(k);
}
static void display(int val = 0)
{
Console.Write(val);
}
Question 4: Which of the following keyword is used to declare a variable whose type will be automatically determined by the compiler?
Question 5: Which of the following data types can include maximum positive or negative, integer or float value?
Question 6: 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)+(b*c));
Console.Write ((a*b)+(b*c)-c);
}
Question 7: Which of the following is the default access modifier in a namespace?
Question 8: A constructor in a class can have a return type.
Question 9: What will be the output of the following program?
public static void Main(string[] args)
{
string str1, str2;
str1 = "C#";
str2 = "C#";
Console.Write(Object.ReferenceEquals(str1, str2));
}
Question 10: What will be the output of the following code?
var greet = "Hello ";
var name = "Steve";
Console.WriteLine($"{greet} {name}");
Question 11: What will be the output of the following program?
int i = 0;
for(;;)
{
if (i < 5)
Console.Write(i);
else
break;
i++;
}
Question 12: The members of the enum are always public, and no access modifiers can be applied.
Question 13: Which of the following is a correct way to initialize an array?
Question 14: Which of the following statement(s) are TRUE?
Question 15: What will be the output of the following code?
SortedList sortedList = new SortedList()
{
{2, true},
{1,"one"},
};
foreach(DictionaryEntry kvp in sortedList )
Console.Write(kvp.Value);
Question 16: What will be the output of the following program?
public static void Main()
{
int val = GetVal();
}
public static int GetVal(){
int[] arr = {1, 2, 3, 4, 5};
try
{
return arr[10];
}
catch(Exception ex){
Console.WriteLine("Error occurred!");
}
finally{
return 0;
}
}
Question 17: 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]);
}
finally{
Console.WriteLine("Error occurred!");
}
}
Question 18: Which of the following statements are TRUE?
Question 19: Which of the following is the built-in delegate function for handling events in .NET?
Question 20: Events can also be declared static, virtual, sealed, and abstract.