Recently while I was attending an interview I came across a question Static vs Singleton. Though I know the differences I couldn’t answer it properly, as I was not refreshed my programming knowledge before the interview.

I would like to quote a reference to Jalpesh’s blog article (www.dotnetjalps.com) explaining the difference:

Difference between Static and Singleton classes:

  1. A singleton classes allowed to create a only single instance or particular class. That instance can be treated as normal object. You can pass that object to a method as parameter or you can call the class method with that Singleton object. While static class can have only static methods and you can not pass static class as parameter.
  2. We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.
  3. We can clone the object of Singleton classes we can not clone the object of static classes.
  4. Singleton objects stored on heap while static class stored in stack.
  5. A Singleton class can extend the classes(support inheritance) while static class can not inherit classes.
  6. Singleton class can initialize lazy way while static class initialize when it loaded first
  7. Static classes are sealed class while Single ton classes are not sealed.

Credits to Jalpesh Vadgama  – “Computer Geek, Developer, Mentor, Life long learner, 10+ Years of Experience in Microsoft.NET Technologies, Awarded Microsoft Mvp(C#) for year 2010,11 and 2012.”


Discover more from Cloud Distilled ~ Nithin Mohan

Subscribe to get the latest posts sent to your email.

By Nithin Mohan TK

Technology Enthusiast | .NET Specialist | Blogger | Gadget & Hardware Geek

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.