SEALED CLASS
When you want to restrict your classes from being inherited
by others you can create the class as sealed class.
SEALED
is a keyword used to define class as sealed class.
A sealed class cannot be inherited by other class. Sealed
Access modifier can be used with method , classes and properties.
Sealed
classes can not be used as base class . hence they can not be considered as
Abstract class.
Eg:
sealed public class SealedClassDemo{
public SealedClassDemo()
{
//
// TODO: Add constructor logic here
//
}
public int Square(int no)
{return no * no;
}
}
No comments:
Post a Comment