Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is true about inheritance in C#?
1) None of the above
2) It allows the creation of multiple instances of a class.
3) It prevents the modification of methods.
4) It allows one class to inherit the methods and properties of another.
Answer : It allows one class to inherit the methods and properties of another.
Which of the following is used to check if a string is null or empty in C#?
1) IsEmpty()
2) String.IsNullOrEmpty()
3) NullCheck()
4) None of the above
Answer : String.IsNullOrEmpty()
What is the output of Console.WriteLine("Hello".Substring(0, 2));?
1) Error
2) Hello
3) He
4) None of the above
Answer : He
Which of the following is used to convert a double to a string in C#?
1) Convert.ToString()
2) Double.ToString()
3) StringConvert()
4) None of the above
Answer : Convert.ToString()
What is the output of Console.WriteLine(10 + 2 * 3);?
1) 10
2) 20
3) 16
4) None of the above
Answer : 16
Which of the following is used to raise an event in C#?
1) OnEvent()
2) RaiseEvent()
3) None of the above
4) EventHandler()
Answer : OnEvent()
Which of the following is a value type in C#?
1) class
2) int
3) string
4) None of the above
Answer : int
What is the output of Console.WriteLine(Math.Abs(-5));?
1) 5
2) 0
3) Error
4) None of the above
Answer : 5
Which of the following is used to implement multiple inheritance in C#?
1) Interface
2) Base class
3) Derived class
4) None of the above
Answer : Interface
What is the output of Console.WriteLine("A" + "B");?
1) AB
2) C
3) Error
4) None of the above
Answer : AB