Difference between Singleton and Static class

By | January 4, 2018

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.

We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.

We can clone the object of Singleton classes we can not clone the object of static classes.

Singleton objects stored on heap while static class stored in stack.

A Singleton class can extend the classes(support inheritance) while static class can not inherit classes.

Singleton class can initialize lazy way while static class initialize when it loaded first

Static classes are sealed class while Single ton classes are not sealed.

 

I hope you will enjoy the difference between Singleton and Static class. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome

Like it? Share it