What are Sealed Classes in C#?
Answers were Sorted based on User's Feedback
A class which restricts inheritance for security region is
called Sealed class.
Sealed class is the last class in hierarchy that why a
sealed class can be a derived class but can never be a base
class.
To access the members of sealed class we should create the
instance object.
Advantages of sealed class is it restrict the third party
vendor for developing new software by inheriting from our
logic.
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / gpriya
A sealed class cannot be inherited. It is an error to use a
sealed class as a base class. Use the sealed modifier in a
class declaration to prevent inheritance of the class.
It is not permitted to use the abstract modifier with a
sealed class.
Structs are implicitly sealed; therefore, they cannot be
inherited.
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / chauhan rakesh botad
sealed classes cannot be inherited.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / chauhan rakesh botad
A class which restricts inheritance for security region is
called Sealed class.
Sealed class is the last class in hierarchy.
Sealed class can be a derived class but can't be a base class.
To access the members of sealed class we should create the
instance object.
Advantages of sealed class is it restrict the third party
vendor for developing new software by inheriting from our logic.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
Answer / uday shah
above answer is correct.sealed class is not inherited and
doesnot make drived class.means sealed class isnot
subclassing.sealed class is only parent class.so selaed
method is not overriding.
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / m.ramkumar
prevent the class in further using subclasses;
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / jp goswsmi
sealed Class that cannot be inherited and used by the other
classes
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vijay pandey
when u add a sealed keyword to the class declaration then the class can not be inherited
1-it is restriction from modification
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ravikumar
all above answers are correct but i have doubt regarding
private classes
| Is This Answer Correct ? | 5 Yes | 5 No |
What problem does Delegate Solve?
What is console write in c#?
Hello Friends..am Mohammed riyash..final year BCA in Jamal Mohamed College 2009. Trichy. My doubt is while connecting SQL2005 Built in Database withing the Visual Studio 2005 Framework.. I am getting the error.. That " An Error occurred and it may be due to , under the default settings of the Server, the connection cannot be established.." But the code works in MS Access for me.. Both in VB.Net and C#.Net am getting the same error.. Any genius please Message me to 9994558822 or mail me.. riyash.ips@gmail.com
Is c# a technology?
What is a property c#?
Why do we need singleton class in c#?
What happens during the process of boxing?
Define constructors
What language is c# similar to?
How you will create satellite assemblies?
Explain the difference between “system.array.clone()” and “system.array.copyto()” in c#?
Explain the process of inheriting a class into another class?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)