What is the primary purpose of using interfaces in C#?
Answer: B
Interfaces define a contract that classes must implement, ensuring consistent method signatures across different implementations. They enable polymorphism and loose coupling.
Q.42Easy
In C# inheritance, which keyword allows accessing members of the parent class?
Answer: B
The 'base' keyword is used to access members (properties, methods) of the parent class from within derived class methods, particularly in constructors and method overriding.
Q.43Easy
Which of the following best describes encapsulation in C#?
Answer: A
Encapsulation is the bundling of data (variables) and methods (functions) into a single unit (class) while hiding the internal details. Access modifiers like private, protected, and public control visibility.
Q.44Easy
What is the purpose of the 'base' keyword in C#?
Answer: B
The 'base' keyword allows a derived class to access members (methods, properties, constructors) of the parent class. It's commonly used to call the parent constructor or override methods while keeping parent functionality.
Q.45Easy
What is the output of this C# code?
public class Employee
{
private string name = "John";
public Employee(string n) { name = n; }
}
Employee emp = new Employee("Alice");
Console.WriteLine(emp.name);
Answer: C
The 'name' field is declared as 'private', so it cannot be accessed outside the class. Attempting to access emp.name from outside the class results in a compilation error.
Advertisement
Q.46Easy
Which of the following best describes the 'this' keyword in C#?
Answer: B
'this' keyword represents the current instance of the class. It is used to access instance members, differentiate between local and instance variables, and pass the current object as a parameter.
Q.47Easy
What is the primary purpose of ASP.NET in web development?
Answer: A
ASP.NET is a server-side web application framework developed by Microsoft for building dynamic, interactive web applications.
Q.48Easy
Which of the following is the latest version of ASP.NET as per 2024-2025?
Answer: B
ASP.NET Core 8.0 is the latest unified platform as of 2024-2025, replacing the older ASP.NET Framework.
Q.49Easy
What does CLR stand for in the context of .NET?
Answer: A
CLR (Common Language Runtime) is the virtual machine that executes .NET code, managing memory, security, and type safety.
Q.50Easy
In ASP.NET Core, what is the purpose of the appsettings.json file?
Answer: A
appsettings.json stores application configuration like connection strings, logging levels, and custom settings.
Q.51Easy
What does MVC stand for in ASP.NET MVC?
Answer: A
MVC (Model-View-Controller) is an architectural pattern separating data (Model), presentation (View), and business logic (Controller).
Q.52Easy
What is the primary purpose of encapsulation in OOP?
Answer: B
Encapsulation bundles data and methods together, hiding internal implementation and controlling access through public interfaces, improving maintainability and security.
Q.53Easy
Which keyword is used to create a class that cannot be instantiated in C#?
Answer: B
The 'abstract' keyword prevents instantiation of a class and forces derived classes to implement abstract members, establishing a contract for subclasses.
Q.54Easy
In C#, what is the correct syntax to implement multiple interfaces in a class?
Answer: A
C# uses colon (:) to implement interfaces, and multiple interfaces are separated by commas. The 'implements' keyword is used in Java, not C#.
Q.55Easy
Which of the following is NOT a pillar of OOP in C#?
Answer: D
The four pillars of OOP are Inheritance, Polymorphism, Encapsulation, and Abstraction. Compilation is a language feature, not an OOP principle.
Q.56Easy
In C#, what is the primary purpose of using an interface?
Answer: B
Interfaces in C# define a set of method and property declarations that implementing classes must provide, establishing a contract without implementation details.
Q.57Easy
Which statement is TRUE about abstract methods in C#?
Answer: B
Abstract methods have no implementation in the abstract class and force derived classes to provide their own implementation. They cannot be private as they must be overridable.
Q.58Easy
Consider a payment processing system where PaymentProcessor is an abstract class with an abstract method ProcessPayment(). CreditCardProcessor and UPIProcessor are derived classes. What will happen if you try to instantiate PaymentProcessor directly in C#?
Answer: B
Abstract classes in C# cannot be instantiated directly. The compiler enforces this rule at compile-time. Abstract classes serve as blueprints and must be inherited by concrete classes that provide implementations for all abstract members. This ensures proper design and forces derived classes to implement required functionality.
Q.59Easy
Which namespace in C# contains the collections like List<T>, Dictionary<K,V>, and Queue<T>?
Answer: A
System.Collections.Generic is the standard namespace for generic collections in C#. It provides type-safe collections that prevent runtime errors.
Q.60Easy
What is the main difference between ArrayList and List<T> in C#?
Answer: B
List<T> is generic and type-safe, preventing boxing/unboxing overhead and providing compile-time type checking. ArrayList stores objects and requires casting.