why do we have to seal a classes if we know that it's not going to inherit to any class.

Recommended Answers

All 2 Replies

Basically from my part I can tell you that it's just a smooth way of writting the code. If you know that you are not going to EXTEND your class then seal it. Personally, I've never used it but I think that other members could tell you more about it. Otherwise just google it or try to find a tutorial on youtube if you really must know about the sealed keyword in depth...

I use sealed for utility classes that have no business being extended. Some people go so far as to seal any classes that aren't explicitly intended to be extended, which is actually a reasonable approach. It makes your intentions crystal clear.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.