Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a way to create an object in C#?
1) ClassName obj = new ClassName();
2) ClassName obj;
3) new ClassName obj;
4) None of the above
Answer : ClassName obj = new ClassName();
What is the purpose of the "async" keyword in C#?
1) To declare a synchronous method
2) To define an asynchronous method
3) To declare a lambda expression
4) None of the above
Answer : To define an asynchronous method
What is the output of Console.WriteLine(Math.Pow(2, 3));?
1) 6
2) 8
3) 9
4) Error
Answer : 8
Which of the following is true about the "ref" keyword in C#?
1) It is used for passing parameters by value.
2) It is used for passing parameters by reference.
3) It is used for declaring a constant.
4) None of the above
Answer : It is used for passing parameters by reference.
What is the output of Console.WriteLine(5 < 10 && 10 > 5);?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is a correct way to define a constant in C#?
1) const int x = 5;
2) readonly int x = 5;
3) static int x = 5;
4) None of the above
Answer : const int x = 5;
What is the output of Console.WriteLine(5 + 3 * 2);?
1) 11
2) 16
3) 10
4) Error
Answer : 11
Which of the following keywords is used to inherit from a base class in C#?
1) base
2) derived
3) extends
4) None of the above
Answer : base
What is the output of Console.WriteLine("123".Length);?
1) 3
2) 2
3) Error
4) None of the above
Answer : 3
Which of the following is true about value types in C#?
1) They are stored in heap.
2) They can be null.
3) They are stored in stack.
4) None of the above
Answer : They are stored in stack.