Interview Questions

Can you prevent your class from being inherited and becoming a base class for some other classes?

C# Interview Questions and Answers


(Continued from previous question...)

37. Can you prevent your class from being inherited and becoming a base class for some other classes?

Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java.

(Continued on next question...)

Other Interview Questions