Sealed Class:
Sealed keyword is used to avoid the inheritance of that class. it cannot be inherited.
In inherited hierarchy Sealed class is the leaf node.
Even a public class is declared as Sealed it will be ban to inherit.
No instance of a Sealed class is possible because we cannot create constructor of it.
Private Class:
Private keyword is used to limit the scope. if we declare a class private within a class means
it will not be visible out of base class.
Private classes cannot be used directly as this will throw compilation error.
We have must nest a private class within another public class.
We can create constructor for a private class so instance of private class is possible.
Private class is only visible to that class it is defined and within it.
Private class can be inherited but a private class cannot be inherited from a public class. because a child class
can not be more accessible than base class. Either parent should be more accessible or equal.
Comments and Suggestions are always Welcome!
No comments:
Post a Comment