Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is used to declare a method in an interface in C#?
1) void MethodName();
2) MethodName();
3) return MethodName();
4) None of the above
Answer : void MethodName();
What is the output of Console.WriteLine("C#".Length);?
1) 2
2) 3
3) 1
4) None of the above
Answer : 2
Which of the following is used to create a new object in C#?
1) new
2) create
3) instance
4) None of the above
Answer : new
What is the output of Console.WriteLine(Math.Pow(2, 3));?
1) 8
2) 6
3) 4
4) Error
Answer : 8
Which of the following is used to get the number of elements in a list in C#?
1) Count
2) Length
3) Size
4) None of the above
Answer : Count
What is the output of Console.WriteLine("C# Programming".IndexOf("P"));?
1) 3
2) 2
3) 4
4) Error
Answer : 3
Which of the following is true about static methods in C#?
1) They can be called without an instance of the class.
2) They can only be called with an instance of the class.
3) They cannot return values.
4) None of the above
Answer : They can be called without an instance of the class.
Which of the following is used to declare a nullable type in C#?
1) ?
2) nullable
3) isNull
4) None of the above
Answer : ?
What is the output of Console.WriteLine(15 % 6);?
1) 3
2) 5
3) 1
4) None of the above
Answer : 3
Which of the following is used to convert a string to an integer in C#?
1) int.Parse()
2) Convert.ToInt()
3) parseInt()
4) None of the above
Answer : int.Parse()