Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is the correct way to declare a nullable type in C#?
1) int? num;
2) int num = null;
3) nullable int num;
4) var num;
Answer : int? num;
What is the keyword used in C# to define a method that does not return a value?
1) void
2) null
3) return
4) none
Answer : void
Which of the following is the base class for all .NET classes?
1) System.Object
2) System.Base
3) System.Class
4) None of the above
Answer : System.Object
Which of the following is used to handle multiple exceptions in C#?
1) try-catch
2) try-catch-finally
3) catch-catch
4) None of the above
Answer : try-catch-finally
What is the correct way to define a delegate in C#?
1) public delegate void MyDelegate();
2) delegate void MyDelegate;
3) public delegate MyDelegate();
4) delegate MyDelegate void();
Answer : public delegate void MyDelegate();
Which method is used to write output to the console in C#?
1) Console.WriteLine()
2) Console.ReadLine()
3) System.Out.Write()
4) System.Out.Read()
Answer : Console.WriteLine()
What is the default access modifier of a class in C#?
1) internal
2) public
3) private
4) protected
Answer : internal
Which of the following is the correct way to create a read-only property in C#?
1) public int Age { get; }
2) public int Age { set; }
3) public readonly int Age;
4) None of the above
Answer : public int Age { get; }
What is the correct way to initialize an array in C#?
1) int[] arr = new int[] { 1, 2, 3 };
2) int[] arr = [1, 2, 3];
3) int arr = new int[] { 1, 2, 3 };
4) int arr[] = { 1, 2, 3 };
Answer : int[] arr = new int[] { 1, 2, 3 };
What is the keyword used to inherit a class in C#?
1) extends
2) inherits
3) base
4) None of the above
Answer : None of the above