2
Reply

difference between sealed class and abstract class?

Amit Jain

Amit Jain

17y
24.8k
0
Reply

    Hi,


    Sealed and abstract are the keywords used in .Net framework.

    Sealed class : A sealed class can not be inherited in other words, no class can be derived from the sealed class. 

    Basically used for commercial reasons where restrictions are implemented on the class so that no one use the existing class and derive from it without the license.

    If a method is declared as sealed it can not be overridden. Used to avoid instability of some major code.

    Abstract Class : A class that contains atleast one abstract method and uses a keyword abstract is a abstract class. It may or may not have the non abstract methods. This class can be inherited.

    Abstract method means that the method does not have any implementation..it just contains the signature of method. The abstract method is required to be implemented in the derived class.



    hei sealed class is one which cannot act as base class.ie u cannot derive a class from it.where as abstract class is a one contains abstract methods & non abstract methods.abstract method is one which doesnt have any implementation.class deriving from abstract class has to provide implementation for bstract methods.