How can we make a class singleton?



How can we make a class singleton?..

Answer / Mohit Jaiswal

"By using the `enum` keyword or by making the constructor private and providing a static method to access the single instance of the class."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

can used Protected Class outside Function.?

1 Answers   HCL,


What is anagram of a string?

1 Answers  


What is a boolean used for?

1 Answers  


What is JDK? Mention the variants of JDK?

1 Answers  


How many bits is a string?

1 Answers  


What are library required to connect to excel sheet.

2 Answers   Cap Gemini,


What is variable argument in java?

1 Answers  


What is mnemonic code?

1 Answers  


how an we achive multiple inhetitance in java using interface..??

2 Answers  


What is the final class?

1 Answers  


How is Garbage collection done in Java?

3 Answers   T3 Softwares,


What is meant by data hiding in java?

1 Answers   Aspire, Infogain,


Categories