Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Java%20Design%20Patterns%20Interview%20Questions%20and%20Answers

Question: What is Singleton design pattern in Java ? write code for thread-safe singleton in Java.
Answer: Singleton pattern focus on sharing of expensive object in whole system. Only one instance of a particular class is maintained in whole application which is shared by all modules. Java.lang.Runtime is a classical example of Singleton design pattern. From Java 5 onwards you can use enum to thread-safe singleton.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook