iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.201Medium

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

Q.202Medium

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

Which statement about abstract classes in C# is INCORRECT?

Q.204Hard

A gaming application needs to implement different weapons (Sword, Gun, Bow) with different attack methods. Which approach is most maintainable?

Q.205Hard

In a complex system where a class needs to inherit from multiple sources of functionality while maintaining a single base type, which C# feature is most appropriate?

Q.206Hard

A financial system implements IEquatable<Account> for comparing accounts. What is the primary benefit of implementing this interface?

Q.207Hard

In a real estate system, consider Property (base) with House and Apartment (derived). If Property has a sealed method CalculateTax(), what happens in House class?

Q.208Medium

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.209Easy

In C#, what is the primary purpose of using an interface?

Q.210Medium

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

Q.211Medium

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

Q.212Medium

Which of the following correctly demonstrates composition in C#?

Q.213Medium

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

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.215Easy

Which statement is TRUE about abstract methods in C#?

Q.216Hard

Consider a scenario where class X implements interfaces IA and IB, and both interfaces have a method named Process(). How should X implement this?

Q.217Hard

In a healthcare system, Doctor is a derived class from Employee. If you want to ensure that Doctor's constructor calls Employee's constructor before executing, which approach is correct?

Q.218Medium

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.219Easy

Consider a payment processing system where PaymentProcessor is an abstract class with an abstract method ProcessPayment(). CreditCardProcessor and UPIProcessor are derived classes. What will happen if you try to instantiate PaymentProcessor directly in C#?

Q.220Easy

Which namespace in C# contains the collections like List<T>, Dictionary<K,V>, and Queue<T>?