0 votes
in JAVA by

What is a singleton class? Give a practical example of its usage.

1 Answer

0 votes
by

A singleton class in java can have only one instance and hence all its methods and variables belong to just one instance. Singleton class concept is useful for the situations when there is a need to limit the number of objects for a class.

The best example of singleton usage scenario is when there is a limit of having only one connection to a database due to some driver limitations or because of any licensing issues.

Related questions

0 votes
asked Jan 24, 2021 in JAVA by rajeshsharma
+1 vote
asked Oct 23, 2020 in JAVA by rahuljain1
...