Preventing Inheritance with sealed/final
Yes. A class can be explicitly prevented from being inherited. Java uses the final keyword, while C# uses sealed. This is useful when a class's behavior must not be changed through inheritance, when invariants depend on the exact implementation, or when an API is intentionally closed for extension. It can also prevent consumers from creating subclasses that violate assumptions made by the class.
Java: final class prevents class inheritance.
C#: sealed class prevents class inheritance.
Useful for preserving invariants and preventing unintended specialization.
Can communicate that extension through inheritance is not part of the API contract.
Sealing a class does not prevent composition or interface-based abstraction.