C# Programming - MCQ Practice Questions
C# (.NET) MCQs — OOP, collections, LINQ & exception handling.
290 questions | 100% Free
What is the output of the following C# code? public class Base { public virtual void Display() { Console.WriteLine("Base"); } } public class Derived : Base { public override void Display() { Console.WriteLine("Derived"); } } Base obj = new Derived(); obj.Display();
A developer creates an abstract class Account with an abstract method CalculateInterest(). Two derived classes SavingsAccount and CurrentAccount implement this method differently. This scenario best demonstrates which OOP principle?
What is the difference between a class and a struct in C#?
In C#, what will be the output of the following code? class Test { public Test() { Console.WriteLine("Constructor"); } ~Test() { Console.WriteLine("Destructor"); } } Test t = new Test(); t = null;
An application needs to define behavior that multiple unrelated classes must follow. Which feature should be used?
A developer implements IComparable interface in a Student class. What must the class implement?
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?
A payment processing system implements multiple interfaces: IPayment, IRefundable, IAuditTrail. A PaymentProcessor class must implement all three. Which statement is true?
In ASP.NET, what is the purpose of the Global.asax file?
Which attribute is used to mark a method as an HTTP endpoint in ASP.NET Core?
What is the difference between ASP.NET Framework and ASP.NET Core?
Which of the following is NOT a built-in state management technique in ASP.NET?
What is the role of Middleware in ASP.NET Core?
In an ASP.NET Core application, where is Dependency Injection configured?
What is the purpose of the [ValidateAntiForgeryToken] attribute in ASP.NET MVC?
Which of the following methods is used to pass data from Controller to View in ASP.NET MVC?
What is Entity Framework in ASP.NET context?
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#?