Sealed class
- It is complete class
- It is allow creating an object
- It is also called instance class
- Inheritance is not possible for Sealed Class. Means No one can be able to inherit from a Sealed Class but sealed class can inherit from any other class (The Parent Class should not be Sealed Class).
- Sealed class can never acts as a Parent Class
- Static class is by default sealed class only.
Example for Sealed Class:
----------------------------------------------------
public sealed class ToyCalc
{
}
public class AdvancedToyCalc : ToyCalc
{
}
Note 1: The above Code is wrong since a sealed class can never act as a Base or Parent Class.
Note 2: But ToyCalc class can inherit from other classes ex.
Ex: public sealed class ToyCalc: Toy
The Toy Class should not be a Static Class or SealedClass.
No comments:
Post a Comment