Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of Console.WriteLine("Hello World".Split()[1]);?
1) World
2) Hello
3) Error
4) None of the above
Answer : World
Which of the following is used to specify that a class cannot be inherited?
1) sealed
2) abstract
3) static
4) None of the above
Answer : sealed
Which of the following is used to declare an event in C#?
1) event EventHandler MyEvent;
2) delegate MyEvent;
3) MyEvent EventHandler;
4) None of the above
Answer : event EventHandler MyEvent;
What is the output of Console.WriteLine("123".ToString());?
1) 123
2) Error
3) 123.0
4) None of the above
Answer : 123
Which of the following is a correct way to initialize an array in C#?
1) int[] arr = new int[5];
2) int arr[5];
3) int arr = new int[5];
4) None of the above
Answer : int[] arr = new int[5];
What is the purpose of the "virtual" keyword in C#?
1) To define a method that can be overridden
2) To define a constant
3) To declare an abstract method
4) None of the above
Answer : To define a method that can be overridden
Which of the following is used to convert a string to an integer in C#?
1) Convert.ToInt32()
2) int.Parse()
3) Both a and b
4) None of the above
Answer : Both a and b
What is the output of Console.WriteLine(2 * 3 + 4);?
1) 10
2) 8
3) 6
4) Error
Answer : 10
Which of the following keywords is used to define a class in C#?
1) class
2) object
3) instance
4) None of the above
Answer : class
What is the output of Console.WriteLine(10 > 5 && 3 < 2);?
1) true
2) false
3) Error
4) None of the above
Answer : false