iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.21Hard

In C# 10, what does the 'file' access modifier allow?

Q.22Hard

Which feature in C# 8+ allows you to provide default implementation in an interface?

Q.23Hard

In C# 12, what feature allows creating parameterless struct constructors with field initializers?

Q.24Hard

What is the correct way to implement the Dispose pattern in C# for resource cleanup?

Q.25Hard

A company develops a payment system using multiple payment methods (Credit Card, UPI, Wallet). Which OOP principle best applies here?

Q.26Hard

Consider a scenario where class C inherits from B, and B inherits from A. If all three have a method Display(), what does calling Display() on C object invoke?

Q.27Hard

In C# 10+, what is the purpose of the 'file-scoped type' modifier?

Q.28Hard

A developer needs to ensure that a method in a derived class cannot be overridden further. Which keyword should be used?

Q.29Hard

In C#, when implementing IDisposable pattern, what should a derived class do if the base class also implements it?

Q.30Hard

What is covariance in C# generics and interfaces?

Q.31Hard

A logging system needs to handle multiple logger types (File, Database, Console) interchangeably. Which design pattern combined with polymorphism best suits this?

Q.32Hard

What will happen if you try to override a non-virtual method in a derived class in C#?

Q.33Hard

A banking application uses inheritance where Account is the parent class and SavingsAccount, CurrentAccount are derived classes. Each has different withdrawal rules. Which design principle is being followed?

Q.34Hard

In a hospital management system, Doctor and Nurse classes need to perform a common Logout() operation but have different Login() procedures. What is the best OOP approach?

Q.35Hard

A web application needs to store a user preference that persists across multiple browser sessions. Which state management technique is most appropriate?

Q.36Hard

What is the correct order of Page Lifecycle events in ASP.NET Web Forms?

Q.37Hard

An e-commerce application needs to handle concurrent user requests efficiently. Which ASP.NET Core feature is most suitable?

Q.38Hard

In ASP.NET Core, which method is used to register services in the dependency injection container?

Q.39Hard

A developer needs to create a RESTful API that returns JSON data. Which ASP.NET approach is most suitable?

Q.40Hard

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