iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.21Easy

Which access modifier allows a member to be accessed only within the same assembly?

Q.22Hard

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

Q.23Medium

What will be the behavior if a base class method is not marked as 'virtual' and a derived class attempts to override it?

Q.24Medium

Which statement about record types in C# 9+ is correct?

Q.25Easy

What is the output of using 'nameof()' operator on a property in C#?

Q.26Medium

In C#, what is the correct way to implement explicit interface implementation?

Q.27Hard

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

Q.28Easy

What happens when you mark a class with the 'sealed' modifier?

Q.29Medium

In C#, what is the relationship between composition and inheritance in OOP design?

Q.30Easy

What does the 'base' keyword do in a derived class method in C#?

Q.31Easy

Which of the following demonstrates proper encapsulation in C#?

Q.32Hard

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

Q.33Hard

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

Q.34Easy

What is the output behavior of ToString() method when not overridden in a custom class?

Q.35Medium

In C# 11, which feature enables you to define constraints on generic type parameters at compile-time?

Q.36Easy

In C#, which access modifier allows a member to be accessed only within the same class?

Q.37Easy

What is the primary purpose of using interfaces in C#?

Q.38Easy

In C# inheritance, which keyword allows accessing members of the parent class?

Q.39Medium

What does the 'virtual' keyword enable in C#?

Q.40Medium

Consider a BankAccount class with private balance field. How should external classes access this field safely?