Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of Console.WriteLine(2 + 3 * 4);?
1) 14
2) 20
3) 14
4) None of the above
Answer : 14
Which of the following is a correct syntax for declaring a variable in C#?
1) int x = 5;
2) x int = 5;
3) 5 int x;
4) None of the above
Answer : int x = 5;
What is the output of Console.WriteLine("C#" + " Programming");?
1) C# Programming
2) C#Programming
3) Error
4) None of the above
Answer : C# Programming
Which keyword is used to define a derived class in C#?
1) inherits
2) extends
3) base
4) None of the above
Answer : base
What is the output of Console.WriteLine(5 / 2);?
1) 2
2) 2.5
3) Error
4) None of the above
Answer : 2
Which of the following is not a valid access modifier in C#?
1) public
2) private
3) protected
4) internalprotected
Answer : internalprotected
What is the purpose of the "virtual" keyword in C#?
1) To define a method that can be overridden.
2) To define a method that cannot be overridden.
3) To create a constructor.
4) None of the above
Answer : To define a method that can be overridden.
What is the output of Console.WriteLine(3 * 4 + 2);?
1) 14
2) 12
3) 10
4) None of the above
Answer : 14
Which of the following is the correct syntax to start a switch statement in C#?
1) switch (expression) {}
2) switch {expression}
3) switch expression {}
4) None of the above
Answer : switch (expression) {}
What does the "return" statement do in C#?
1) Ends the execution of a method and returns a value.
2) Ends the program.
3) Returns control to the calling method.
4) None of the above
Answer : Ends the execution of a method and returns a value.