What is sealed class?

 Posted by Manicse on 10/12/2016 | Category: OOPS Interview questions | Views: 140 | Points: 40
Answer:

Sealed classes are those classes which can not be inherited and thus any sealed class member can not be derived in any other class. A sealed class cannot also be an abstract class.

Simple Sealed Class.
sealed class SealedClass 

{

}


Simple Example Programming:

using System;

class ClassSeal

{

static void Main(string[] args)
{
SealedClass sealedCls = new SealedClass(); //Sealed class declaration
int total = sealedCls.Multiple(14, 53);
Console.WriteLine("Total = " + total.ToString());
}

}

// Sealed class Definition

sealed class SealedClass

{
public int Multiple(int x, int y)
{
return x * y;
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response