Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is used to throw an exception in C#?
1) throw
2) raise
3) exception
4) None of the above
Answer : throw
What is the output of Console.WriteLine(Math.Sqrt(16));?
1) 4
2) 16
3) Error
4) None of the above
Answer : 4
Which of the following is true about destructors in C#?
1) They are used to clean up resources.
2) They are called when an object is created.
3) They return a value.
4) None of the above
Answer : They are used to clean up resources.
What is the output of Console.WriteLine("CSharp".Replace("C", "c"));?
1) cSharp
2) Csharp
3) CSHARP
4) None of the above
Answer : cSharp
Which of the following is used to remove whitespace from a string in C#?
1) Trim()
2) Strip()
3) Clear()
4) None of the above
Answer : Trim()
What is the output of Console.WriteLine(10 % 3);?
1) 1
2) 3
3) 0
4) None of the above
Answer : 1
Which of the following is used to declare a constant in C#?
1) const
2) readonly
3) constant
4) None of the above
Answer : const
Which of the following is true about the "static" keyword in C#?
1) It allows multiple instances of a class.
2) It prevents the execution of a method.
3) It makes a member belong to the type itself rather than to a specific object.
4) None of the above
Answer : It makes a member belong to the type itself rather than to a specific object.
What is the output of Console.WriteLine("10" + 10);?
1) 20
2) Error
3) None of the above
4) 1010
Answer : 1010
Which of the following is used to read a line from the console in C#?
1) Console.Read()
2) None of the above
3) Console.Input()
4) Console.ReadLine()
Answer : Console.ReadLine()