Anant Kulkarni
What is the difference between Singleton and Static class
  • Manas Mohapatra
    Jul, 2015 14

    Singleton: 1. Singleton class contains both static and non-static members 2. You can create instance of Singleton class. 3. You can implement inheritance. 4. You can clone a singleton class object. 5. Singleton class object creates in Heap memory. Static Class: 1. Static class contains only static members. 2. You can't create instance of Static class. 3. Once you declare a class as static you can't implement inheritance. 4. You can't clone static class object. 5. Static class object creates in stack memory.

    • 6
  • Akash Varshney
    Oct, 2015 10

    Main difference between in Singleton and Static . Singleton will be available when its needed in the program. you dont need to allocate memory if its not required at the starting time of application. Static will be initialized at the beginning time it self. and it will be available at the program.

    • 5
  • Sudheshwer  Rai
    Jun, 2015 26

    Singleton Class : We use this when we need to create only a single instance of the class.Static Class : Static Class can have static constructor but it can't have instance constructor. It calls automatically when program loads in memory.

    • 3
  • Bhuvanesh Mohankumar
    May, 2016 5

    Singleton: single instance can be created at any point of time.Static: No instance of the class is created.

    • 2
  • Prakash Tripathi
    Jul, 2015 14

    Please have a look at below article, it may help. http://www.c-sharpcorner.com/uploadfile/19b1bd/design-patterns-simplified-part-2-singleton/

    • 2
  • Sujeet Suman
    Jun, 2015 17

    Singleton Class: you can create one instance of the object and reuse it. Singleton instance is created for the first time when the user requested. singleton class can have constructor.Static Class: You can not create the instance of static class. are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded. Static Class class cannot have constructor.

    • 2
  • Mohammad Ilyas
    Jun, 2017 14

    Singleton class can be inherited from another class. Static class cannot be inherited.

    • 1
  • Maruthi Palllamalli
    Mar, 2016 9

    You cannot apply new keyword to both static class and singleton classes. But CLR will load this static class, you can only load singleton class.

    • 1
  • Munesh Sharma
    Jun, 2015 16

    http://javarevisited.blogspot.in/2013/03/difference-between-singleton-pattern-vs-static-class-java.html

    • 1
  • Anant Kulkarni
    May, 2015 21

    The Singleton class should be used where an instance of an object is required to be passed to some method. Since static class object cannot be created, we wont be able to pass it around as an instance.

    • 1
  • Navneet Arora
    May, 2018 23

    A static class can be used as a container for collection of methods that are dependent on input parameters. It has the following characteristics:- Contains only static members.- Cannot be instantiated.- Is sealed.- Cannot contain Instance Constructors.The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created.A singleton class is used when you need only one instance. A singleton class has a private constructor. A private constructor prevents the class from being instantiated again.A singleton class can have instance members, while a static class cannot.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS