Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of Console.WriteLine(10 / 2 + 3);?
1) 8
2) 7
3) 6
4) Error
Answer : 8
Which of the following is used to create an exception in C#?
1) throw new Exception();
2) new Exception();
3) create Exception();
4) None of the above
Answer : throw new Exception();
What is the output of Console.WriteLine("5" + "5");?
1) 10
2) 55
3) Error
4) None of the above
Answer : 55
Which of the following is a way to define a property in C#?
1) public int Property { get; set; }
2) public int Property() { }
3) public int Property;
4) None of the above
Answer : public int Property { get; set; }
Which of the following is used to define a constructor in C#?
1) public ClassName() {}
2) ClassName() {}
3) void ClassName() {}
4) None of the above
Answer : public ClassName() {}
What is the output of Console.WriteLine("abc".Substring(1, 2));?
1) bc
2) ab
3) c
4) Error
Answer : bc
Which of the following statements is used to declare an interface in C#?
1) interface IMyInterface {}
2) class IMyInterface {}
3) public IMyInterface {}
4) None of the above
Answer : interface IMyInterface {}
What is the output of Console.WriteLine(9 % 4);?
1) 1
2) 2
3) 3
4) Error
Answer : 1
Which of the following statements about properties in C# is true?
1) Properties can only have get accessors.
2) Properties can have both get and set accessors.
3) Properties cannot be static.
4) None of the above
Answer : Properties can have both get and set accessors.
What is the output of Console.WriteLine(3.5 + 2);?
1) 5.5
2) 5
3) Error
4) None of the above
Answer : 5.5