C# Interview Question #29
What is a sealed class in C#?
Classes, Constructors & Properties Junior Beginner
Quick Interview Answer
A sealed class cannot be inherited. It is useful when a type's behavior should not be extended through class inheritance.
Detailed Explanation
A sealed class cannot be inherited. It is useful when a type's behavior should not be extended through class inheritance.
The sealed keyword can also be applied to an overridden member to prevent classes further down the inheritance hierarchy from overriding that member again.
Code Example
public sealed class PaymentService
{
}
// This would not compile:
// public class CustomPaymentService : PaymentService { }