Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a property of the Exception class in C#?
1) Message
2) StackTrace
3) InnerException
4) All of the above
Answer : All of the above
What is the default value of an uninitialized integer in C#?
1) 0
2) 1
3) null
4) undefined
Answer : Option 1
Which of the following is used to define a method that can be overridden in C#?
1) virtual
2) override
3) abstract
4) None of the above
Answer : virtual
What is the output of Console.WriteLine(3 * 4 - 2);?
1) 10
2) 12
3) 14
4) Error
Answer : 10
Which of the following is used to create a new thread in C#?
1) Thread t = new Thread();
2) Thread t;
3) new Thread();
4) None of the above
Answer : Thread t = new Thread();
What does the "sealed" keyword do in C#?
1) Prevents a class from being inherited
2) Allows a class to be inherited
3) Marks a method as not overridable
4) None of the above
Answer : Prevents a class from being inherited
Which of the following is true about the string type in C#?
1) Strings are mutable.
2) Strings are immutable.
3) Strings can contain null.
4) None of the above
Answer : Strings are immutable.
What is the output of Console.WriteLine(7 - 2 * 3);?
1) 1
2) 7
3) 2
4) Error
Answer : 1
Which of the following is the correct way to define a tuple in C#?
1) var tuple = (1, "apple");
2) var tuple = new Tuple<int, string>(1, "apple");
3) Both a and b
4) None of the above
Answer : Both a and b
What is the output of Console.WriteLine("Hello".StartsWith("H"));?
1) true
2) false
3) Error
4) None of the above
Answer : true