Appear in Online Interview to test your skills and be ready for job!
Twitter Twitter LinkedIn YouTube Google
Be Interview ready ! | Search
Submit content and win cash & prizes monthly.
Winners

Win Prizes

Announcements
Like us on Facebook
Sponsor
Top Articles Author
Thu, 24-Apr-2014 Authors
Goud.Kv
280
All Time Authors
Rajkatie
20480
Vishal@Neeraj
19600
Bharathi Cherukuri
18040

Latest members | More ...


(Statistics delayed by 5 minutes)

Difference between sealed and static classes

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

sealed classes:

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

ex:

sealed class demo
{

}

class abc:demo
{
--Wrong
}
2)They can contain static as well as nonstatic members.

static classes:

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

ex:
static class Program
{

}

2)They can have static members only.


Asked In: Many Interviews | Alert Moderator 

Found interesting? Add this to:




Comments or Responses

Posted by: Umarali1981 on: 8/9/2012 | Points: 10

Also, include the below one as third point,

3)Static classes are used when a class provides functionality that is not specific to any unique instance.

3)Sealed classes are mainly used to prevent inheritance features of object oriented programming.

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.

Comments / Responses
Select text & click toolbar to format. Formatting appears in viewmode only. HTML Tags are not allowed.
Bold Italic Underline Paragraph Title Code  Link 
 Wait ... Processing ..... please wait.