C# Programming - MCQ Practice Questions
C# (.NET) MCQs — OOP, collections, LINQ & exception handling.
290 questions | 100% Free
A developer implements IComparable interface in a Student class. What must the class implement?
What will happen if you try to override a non-virtual method in a derived class in C#?
A banking application uses inheritance where Account is the parent class and SavingsAccount, CurrentAccount are derived classes. Each has different withdrawal rules. Which design principle is being followed?
What is the correct order of constructor execution in multilevel inheritance? class A { public A() { Console.WriteLine("A"); } } class B : A { public B() { Console.WriteLine("B"); } } class C : B { public C() { Console.WriteLine("C"); } } new C();
An e-commerce system needs to ensure that a Product class cannot be instantiated directly but can be inherited. Additionally, it must define some concrete methods and some abstract methods. Which approach is best?
What is the output of this C# code? public class Employee { private string name = "John"; public Employee(string n) { name = n; } } Employee emp = new Employee("Alice"); Console.WriteLine(emp.name);
A payment processing system implements multiple interfaces: IPayment, IRefundable, IAuditTrail. A PaymentProcessor class must implement all three. Which statement is true?
Which of the following best describes the 'this' keyword in C#?
In a hospital management system, Doctor and Nurse classes need to perform a common Logout() operation but have different Login() procedures. What is the best OOP approach?
What is the primary purpose of encapsulation in OOP?
Which keyword is used to create a class that cannot be instantiated in C#?
In a library management system, multiple types of items (Book, Magazine, DVD) share common properties like ID and Title. Which OOP principle should be applied here?
What is the difference between 'sealed' and 'abstract' keywords in C#?
A vehicle management system requires different vehicle types (Car, Bike, Truck) to calculate toll fees differently. Which feature should be used?
In C#, what is the correct syntax to implement multiple interfaces in a class?
Which of the following statements about virtual methods in C# is TRUE?
A restaurant ordering system needs to ensure each order has a unique ID generated automatically. Which design pattern and feature should be used?
What is the output of the following C# code? public class Animal { public virtual void Sound() { Console.WriteLine("Some sound"); } } public class Dog : Animal { public override void Sound() { Console.WriteLine("Bark"); } } Animal animal = new Dog(); animal.Sound();
In an inventory management system, a Product class has a Price property. Which approach best ensures price cannot be negative?
Which of the following is NOT a pillar of OOP in C#?