Skip to main content

What happens when you mark a class as sealed?

Senior C#
Quick Answer A sealed class cannot be inherited รขโ‚ฌโ€ no subclasses allowed. It prevents unintended extension and lets the compiler optimize virtual method calls. The string class is sealed. Use it when your class is complete as-is and inheritance would break its design.

Answer

A sealed class cannot be inherited. It prevents further extension and allows the compiler to optimize method calls.

It is commonly used to avoid misuse or unintended inheritance.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice