Home > Interviews > OOPS >

Difference between sealed and static classes

 Posted by Ddd on 2/2/2011 | Category: OOPS Interview questions | Views: 7396 | Points: 40

sealed classes:

1)we can create their instances, but cannot inherit them


sealed class demo


class abc:demo
2)They can contain static as well as nonstatic members.

static classes:

1)we can neither create their instances, nor inherit them

static class Program


2)They can have static members only.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Singhmanish2211 on: 8/3/2013 | Points: 10
One thing is missing about when to use sealed class and when to use static class in all the forums :

If you want your class to have different behavior's for their instances go for sealed class whereas if you want a unique behavior for the instances of your class go for static class were only one instance will be available at any given time.

Login to post response