in Education by

How can you create Singleton class in java?

1 Answer

0 votes
by
How can you create Singleton class in java? It is two step process. First, make the constructor private so that new operator cannot be used to instantiate the class. Return an object of the object if not null otherwise create the object and return the same via a method.

Related questions

0 votes
    Can we create a clone of a singleton object?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    What is singleton class in android?...
asked Jan 14, 2021 in Technology by JackTerrance
0 votes
    What are the difference between a static class and a singleton class?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    How to prevent cloning of a singleton object?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    How to create an immutable class in JAVA?...
asked May 19, 2021 in Technology by JackTerrance
0 votes
    I'm using JEE and I created EJB-Singleton. It has as a field LRUMap, which represents cache to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Which annoatation is used to inject singleton services like timer service into an ejb?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    What is Singleton pattern?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    I am wanting to find the distance between two different points. This I know can be accomplished with the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    how can you personalize your computer and create files and folders Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    how can you create a link to your emali address using (A) tag Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    How can you create a node for comment in JavaScript? (a) comment() (b) createComment() (c) comm( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    How can you create many to many relationships under salesforce? (1)Creating direct many to many relationships (2) ... (4)Not possible to create many relationships in salesforce...
asked Aug 26, 2021 in Technology by JackTerrance
0 votes
    How can you create many to many relationships under salesforce? 1. Using a piece of code to relate both ... in salesforce 4. Creating direct many to many relationships...
asked Jun 27, 2021 in Technology by JackTerrance
...