Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of Console.WriteLine(Math.Pow(2, 3));?
1) 6
2) 8
3) 9
4) None of the above
Answer : 8
Which of the following is a method of the string class in C#?
1) Substring()
2) IndexOf()
3) Split()
4) All of the above
Answer : All of the above
What is the purpose of the "this" keyword in C#?
1) To refer to the current instance of the class.
2) To define a static method.
3) To create a new instance of the class.
4) None of the above
Answer : To refer to the current instance of the class.
What is the output of Console.WriteLine("5" + 5);?
1) 55
2) 10
3) 5
4) None of the above
Answer : 55
What is the output of Console.WriteLine(10 % 3);?
1) 1
2) 3
3) 0
4) Error
Answer : 1
Which of the following is used to define a static class in C#?
1) static class MyClass {}
2) class MyClass static {}
3) class MyClass { static }
4) None of the above
Answer : static class MyClass {}
What is the output of Console.WriteLine(3 * 3 + 3);?
1) 12
2) 9
3) 6
4) None of the above
Answer : 12
Which keyword is used to define an interface in C#?
1) interface
2) abstract
3) class
4) None of the above
Answer : interface
What is the purpose of the "sealed" keyword in C#?
1) To prevent a class from being inherited.
2) To define a constant.
3) To create a static method.
4) None of the above
Answer : To prevent a class from being inherited.
What is the output of Console.WriteLine(4 + "5");?
1) 45
2) 9
3) Error
4) None of the above
Answer : 45