iGET

C# Programming - MCQ Practice Questions

C# (.NET) MCQs — OOP, collections, LINQ & exception handling.

290 questions | 100% Free

Q.61Medium

A developer implements IComparable interface in a Student class. What must the class implement?

Q.62Hard

What will happen if you try to override a non-virtual method in a derived class in C#?

Q.63Hard

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?

Q.64Medium

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();

Q.65Medium

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?

Q.66Easy

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);

Q.67Medium

A payment processing system implements multiple interfaces: IPayment, IRefundable, IAuditTrail. A PaymentProcessor class must implement all three. Which statement is true?

Q.68Easy

Which of the following best describes the 'this' keyword in C#?

Q.69Hard

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?

Q.70Easy

What is the primary purpose of encapsulation in OOP?

Q.71Easy

Which keyword is used to create a class that cannot be instantiated in C#?

Q.72Medium

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?

Q.73Medium

What is the difference between 'sealed' and 'abstract' keywords in C#?

Q.74Medium

A vehicle management system requires different vehicle types (Car, Bike, Truck) to calculate toll fees differently. Which feature should be used?

Q.75Easy

In C#, what is the correct syntax to implement multiple interfaces in a class?

Q.76Medium

Which of the following statements about virtual methods in C# is TRUE?

Q.77Medium

A restaurant ordering system needs to ensure each order has a unique ID generated automatically. Which design pattern and feature should be used?

Q.78Medium

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();

Q.79Medium

In an inventory management system, a Product class has a Price property. Which approach best ensures price cannot be negative?

Q.80Easy

Which of the following is NOT a pillar of OOP in C#?