top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is sealed class in C#? Can anyone give the example?

0 votes
What is sealed class in C#? Can anyone give the example?
posted Mar 7, 2016 by Naveen Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Sealed Class

Sealed class is used to define the inheritance level of a class.

The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class.

Some points to remember:

  1. A class, which restricts inheritance for security reason is declared, sealed class.
  2. Sealed class is the last class in the hierarchy.
  3. Sealed class can be a derived class but can't be a base class.
  4. A sealed class cannot also be an abstract class. Because abstract class has to provide functionality and here we are
    restricting it to inherit.

Practical demonstration of sealed class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace sealed_class
class Program
public sealed class BaseClass
public void Display()
Console.WriteLine("This is a sealed class which can;t be further inherited");

    public class Derived : BaseClass
        // this Derived class can;t inherit BaseClass because it is sealed

    static void Main(string[] args)
        BaseClass obj = new BaseClass();




answer Mar 8, 2016 by Vishi Gulati
Similar Questions
+1 vote

Need to know class definition? Interface definition ? and distinguish between to of them???

+3 votes

By-default all the methods & variables in class are private.

In Main() method is private then how compiler access this Main() Method out side the class because compiler is not part of our program then how compiler access this Main() method?

Here we loose our data abstraction property ? Can anyone put some light on it?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.