Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following can be used to stop a loop in C#?
1) continue
2) break
3) return
4) exit
Answer : break
What is the output of Console.WriteLine("Hello" + " World");?
1) Hello World
2) HelloWorld
3) Hello+World
4) None of the above
Answer : Hello World
Which of the following is a correct declaration of a method in C#?
1) public void MyMethod() {}
2) void MyMethod() {}
3) public MyMethod() {}
4) None of the above
Answer : public void MyMethod() {}
What is the output of Console.WriteLine(10 / 0);?
1) Infinity
2) Error
3) 0
4) None of the above
Answer : Error
Which of the following is used for exception handling in C#?
1) try-catch
2) catch-finally
3) try-finally
4) All of the above
Answer : All of the above
What is the purpose of the "using" statement in C#?
1) To define namespaces
2) To include files
3) To manage resources
4) None of the above
Answer : To manage resources
Which of the following can be used to define a class in C#?
1) class ClassName { }
2) define ClassName { }
3) class ClassName;
4) None of the above
Answer : class ClassName { }
What is the output of Console.WriteLine("abc".Substring(1, 2));?
1) bc
2) ab
3) Error
4) None of the above
Answer : bc
Which of the following is a valid lambda expression in C#?
1) x => x * x
2) x = > x * x
3) x -> x * x
4) None of the above
Answer : x => x * x
What does the "static" keyword signify in C#?
1) The method belongs to the instance
2) The method belongs to the class
3) The method is private
4) None of the above
Answer : The method belongs to the class