C# Programming - MCQ Practice Questions
C# (.NET) MCQs — OOP, collections, LINQ & exception handling.
290 questions | 100% Free
A student management system implements IComparable<Student> to sort students. Which method must be implemented?
What happens when a derived class constructor does not explicitly call the base class constructor in C#?
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?
Which statement about abstract classes in C# is INCORRECT?
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();
Which keyword in C# is used to prevent a class from being inherited?
What will be the result of the following C# code? class Animal { } class Dog : Animal { } Dog dog = new Animal(); // Line 1
Which of the following correctly demonstrates composition in C#?
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?
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?
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?