Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is the correct way to define an abstract class in C#?
1) abstract class MyClass {}
2) class MyClass abstract {}
3) class abstract MyClass {}
4) None of the above
Answer : abstract class MyClass {}
What is the output of Console.WriteLine(1 == 1 && 2 == 2);?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is used to create a new thread in C#?
1) Thread t = new Thread();
2) Thread t = new Thread(MyMethod);
3) new Thread(MyMethod);
4) None of the above
Answer : Thread t = new Thread(MyMethod);
What is the output of Console.WriteLine("Hello".EndsWith("lo"));?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is not a valid way to declare a string in C#?
1) string str = "Hello";
2) string str = new String();
3) string str;
4) None of the above
Answer : string str = new String();
What is the output of Console.WriteLine(5 / 2);?
1) 2
2) 2.5
3) 3
4) None of the above
Answer : 2
Which of the following is a valid way to define an event handler in C#?
1) void MyEventHandler(object sender, EventArgs e) {}
2) MyEventHandler(object sender, EventArgs e) {}
3) void MyEventHandler; {}
4) None of the above
Answer : void MyEventHandler(object sender, EventArgs e) {}
What is the purpose of the "using" statement in C#?
1) To include namespaces.
2) To ensure IDisposable objects are disposed.
3) To define a block of code.
4) None of the above
Answer : To ensure IDisposable objects are disposed.
What is the output of Console.WriteLine(2 * 3 + 4 / 2);?
1) 10
2) 8
3) 7
4) None of the above
Answer : 10
Which of the following statements is true about "null" in C#?
1) Null is a value type.
2) Null cannot be assigned to reference types.
3) Null can be assigned to any variable.
4) None of the above
Answer : Null can be assigned to any variable.