Home Subjects C# Programming

C# Programming

C# and .NET for campus placement

154 Q 4 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 61–70 of 154
Topics in C# Programming
Q.61 Medium ASP.NET Basics
What is the role of Middleware in ASP.NET Core?
A To process HTTP requests and responses in a pipeline
B To manage database connections
C To encrypt sensitive data
D To compile C# code
Correct Answer:  A. To process HTTP requests and responses in a pipeline
EXPLANATION

Middleware components handle cross-cutting concerns like authentication, logging, and exception handling in the request pipeline.

Test
Q.62 Medium ASP.NET Basics
Which of the following is NOT a built-in state management technique in ASP.NET?
A ViewState
B Session State
C Application State
D Block State
Correct Answer:  D. Block State
EXPLANATION

ViewState, Session State, Application State, and Cookies are valid state management techniques. Block State is not a standard ASP.NET technique.

Test
Q.63 Medium ASP.NET Basics
What is the difference between ASP.NET Framework and ASP.NET Core?
A ASP.NET Core is cross-platform while Framework runs only on Windows
B Framework is newer than Core
C Core only supports MVC pattern
D Framework and Core are identical
Correct Answer:  A. ASP.NET Core is cross-platform while Framework runs only on Windows
EXPLANATION

ASP.NET Core is cross-platform (Windows, Linux, macOS) and open-source, while ASP.NET Framework is Windows-only.

Test
Q.64 Medium ASP.NET Basics
Which attribute is used to mark a method as an HTTP endpoint in ASP.NET Core?
A [Route]
B [HttpGet]
C [ApiController]
D [EndPoint]
Correct Answer:  B. [HttpGet]
EXPLANATION

[HttpGet], [HttpPost], [HttpPut], [HttpDelete] attributes define HTTP methods for controller actions in ASP.NET Core.

Test
Q.65 Medium ASP.NET Basics
In ASP.NET, what is the purpose of the Global.asax file?
A To define application-level events and methods
B To store database connection strings
C To configure web server settings
D To manage user authentication only
Correct Answer:  A. To define application-level events and methods
EXPLANATION

Global.asax handles application-level events like Application_Start, Application_End, and Session_Start.

Test
Q.66 Medium OOP in C#
A payment processing system implements multiple interfaces: IPayment, IRefundable, IAuditTrail. A PaymentProcessor class must implement all three. Which statement is true?
A C# does not support multiple interface implementation
B Only one interface can be implemented at a time
C PaymentProcessor can implement all three interfaces and must implement all their methods
D Multiple interface implementation requires abstract classes
Correct Answer:  C. PaymentProcessor can implement all three interfaces and must implement all their methods
EXPLANATION

C# supports multiple interface implementation. A class can implement multiple interfaces separated by commas, and must implement all abstract members of each interface.

Test
Q.67 Medium OOP in 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 Use an Interface
B Use a Sealed Class with virtual methods
C Use an Abstract Class
D Use a Static Class
Correct Answer:  C. Use an Abstract Class
EXPLANATION

Abstract classes can have both concrete (implemented) and abstract (unimplemented) methods. They cannot be instantiated directly but can be inherited. This perfectly fits the requirement.

Test
Q.68 Medium OOP in C#
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();
A C B A
B A B C
C B A C
D A C B
Correct Answer:  B. A B C
EXPLANATION

Constructor execution follows from parent to child. When C() is called, it implicitly calls B() which calls A(). So output is: A B C. Base class constructors execute before derived class constructors.

Test
Q.69 Medium OOP in C#
A developer implements IComparable interface in a Student class. What must the class implement?
A CompareTo() method only
B Equals() and GetHashCode() methods only
C ToString() method only
D All abstract and virtual methods of the interface
Correct Answer:  A. CompareTo() method only
EXPLANATION

IComparable interface requires implementing the CompareTo() method, which defines how objects of the class should be compared for sorting purposes.

Test
Q.70 Medium OOP in C#
An application needs to define behavior that multiple unrelated classes must follow. Which feature should be used?
A Abstract Class
B Interface
C Base Class with virtual methods
D Sealed Class
Correct Answer:  B. Interface
EXPLANATION

Interfaces define contracts that unrelated classes can implement. If classes have common inheritance relationship, abstract classes are better. Interfaces support multiple implementation, making them ideal for unrelated classes.

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips