Select from following answers:- Sealed Classes can be instantiated.
- Sealed keyword is used for declaring class.
- Sealed classes are used to restrict the inheritance feature of object oriented programming.
- Sealed classes are primarily used to prevent derivation.
- All Above
Above all statements are correct about Sealed Class.We can not inherit Sealed Class.That is the reason,it can not be derived.
For Example:-
public sealed class s1
{
Public void Print() {Console.WriteLine("Hello");}
}
//Now if we inherit Sealed class like below:-
public class s2 : s1
{
}
If we compile above code,then it will give an error saying that cannot derive from sealed type member.So we can not derive sealed class.But can instantiate.
Show Correct Answer
Asked In: Many Interviews |
Alert Moderator