Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
See more:
i am getting confusion can any one tell me what is exact difference between these three one word answer is enough


Thanks in advance
Posted

Signleton is not a language class or class specific attribute. It is a design pattern by which can can maintain a object lifetime of a class object for the whole application life.
Sealed class is a class that you can not extended/inherit.
Static Class is a class you need to create all member under that class should be static. You can not create instance of that class.
The based on their characteristics, you can declare/create that type of class based on your problem context.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Feb-13 0:15am    
Correct, a 5. I would recommend not answering non-questions though.
—SA
Rusty Bullet 22-Jul-20 9:46am    
It is a valid question. The answers were also right on the money.
Singleton is Design Pattern in which you make the constructor private so that its object cannot be declare directly, you will need to create Instance of the class and than you can use it.

C#
public class Singleton {
   private static final Singleton instance;   
 
   private Singleton(){}
 
   public static Singleton getInstance() {
     if (instance == null)
       instance = new Singleton();
     return instance;
   }
 }



C#
public Singleton singleton = Singleton.getInstance();



Sealed Class:
Just go through this points and you will get idea of sealed class

1. A class, which restricts inheritance for security reason is declared, sealed class.
2. Sealed class is the last class in the hierarchy.
3. Sealed class can be a derived class but can't be a base class.
4. A sealed class cannot also be an abstract class. Because abstract class has to provide functionality and here we are restricting it to inherit.

Static Class:
Static class is used where you have some utilities lib in you project and you can create common class and can set as Static class
Static classes only contain static members.
Static classes can not be instantiated. They cannot contain Instance Constructors
 
Share this answer
 
v2
Comments
Tejas Vaishnav 25-Feb-13 0:19am    
My 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900