Answer Posted / saba
Sealed classes are used to restrict the inheritance feature
of object oriented programming. Once a class is defined as
sealed class, this class cannot be inherited.
The following class definition defines a sealed class in C#:
// Sealed class
sealed class SealedClass
{
}
In the following code, I create a sealed class SealedClass
and use it from Class1. If you run this code, it will work
fine. But if you try to derive a class from sealed class,
you will get an error.
using System;
class Class1
{
static void Main(string[] args)
{
SealedClass sealedCls = new SealedClass();
int total = sealedCls.Add(4, 5);
Console.WriteLine("Total = " + total.ToString());
}
}
// Sealed class
sealed class SealedClass
{
public int Add(int x, int y)
{
return x + y;
}
}
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Explain the features of an abstract class in net.
Explain the difference between Response.Write () and Response.Output.Write ().
What is a static in c#?
What is assembly manifest?
Is string value type c#?
What is the difference between static and private constructor?
What's the difference between abstraction and encapsulation?
What is ControlBox Propertie
I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?
Differentiate between response.expires and response.expiresabsolute?
What is private constructor c#?
Is dictionary a collection?
What is the diff between the System.Array.CopyTo() and System.Array.Clone()?
What is difference between function and method in c#?
How to create multi-dimensional array?