I wanted to blog about this for a while, b'cos I found many folks not being able to answer this question during the interview process. Few differences worth mentioning are
- Singletons can implement interfaces and inherit from other classes (while static classes cannot).
- Singletons can be extended (used as a subclass) while static classes cannot.
- There is only one instance in case of Singletons but there is none in case of Static classes.
- Singletons can be passed around as a parameter to function calls but you can't do that with a Static class.
2 comments:
Abe saale, ye .net 3.0 ki baaten mat likh please. We are still in 2.0
Post a Comment