iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.101Medium

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

Q.102Medium

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

Q.103Medium

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

Q.104Medium

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.105Medium

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

Q.106Medium

A student management system implements IComparable<Student> to sort students. Which method must be implemented?

Q.107Medium

What happens when a derived class constructor does not explicitly call the base class constructor in C#?

Q.108Medium

In a company payroll system, Employee is the base class with CalculateSalary() as virtual method. Manager and Intern classes override it differently. Why is this design preferred?

Q.109Medium

Which statement about abstract classes in C# is INCORRECT?

Q.110Medium

What is the output of the following C# code? class Base { public virtual void Display() { Console.WriteLine("Base"); } } class Derived : Base { public override void Display() { Console.WriteLine("Derived"); } } Base obj = new Derived(); obj.Display();

Q.111Medium

Which keyword in C# is used to prevent a class from being inherited?

Q.112Medium

What will be the result of the following C# code? class Animal { } class Dog : Animal { } Dog dog = new Animal(); // Line 1

Q.113Medium

Which of the following correctly demonstrates composition in C#?

Q.114Medium

In a banking application, you need to create a base class that cannot be instantiated but defines common properties for SavingsAccount and CheckingAccount. Which should you use?

Q.115Medium

In a logistics system, both Truck and Bicycle need to calculate delivery cost. Instead of duplicating code, you decide to use an interface. What advantage does this provide?

Q.116Medium

In a real-time inventory management system, a Product class needs to track stock levels that should not be modified directly from outside the class. Which OOP principle should be applied here, and how?

Q.117Medium

Which method removes all elements from a collection in C#?

Q.118Medium

What is the time complexity of accessing an element by index in a List<T>?

Q.119Medium

Which collection maintains insertion order but uses a hash table for faster lookups?

Q.120Medium

What happens when you try to access an index beyond the Count in a List<T>?

C# Programming MCQs – Free Practice Tests | iGET | iGET