iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.81Medium

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

Q.82Medium

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?

Q.83Medium

What is the difference between a class and a struct in C#?

Q.84Medium

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;

Q.85Medium

An application needs to define behavior that multiple unrelated classes must follow. Which feature should be used?

Q.86Medium

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

Q.87Medium

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

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

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

Q.90Medium

In ASP.NET, what is the purpose of the Global.asax file?

Q.91Medium

Which attribute is used to mark a method as an HTTP endpoint in ASP.NET Core?

Q.92Medium

What is the difference between ASP.NET Framework and ASP.NET Core?

Q.93Medium

Which of the following is NOT a built-in state management technique in ASP.NET?

Q.94Medium

What is the role of Middleware in ASP.NET Core?

Q.95Medium

In an ASP.NET Core application, where is Dependency Injection configured?

Q.96Medium

What is the purpose of the [ValidateAntiForgeryToken] attribute in ASP.NET MVC?

Q.97Medium

Which of the following methods is used to pass data from Controller to View in ASP.NET MVC?

Q.98Medium

What is Entity Framework in ASP.NET context?

Q.99Medium

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

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

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