Write code that allows to create only one instance of a class?



Write code that allows to create only one instance of a class?..

Answer / Reena Rani

Here is an example in Java using the singleton design pattern:n```npublic class Singleton {n private static final Singleton INSTANCE = new Singleton();n private Singleton() {}n public static Singleton getInstance() {n return INSTANCE;n }n}n``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Code AllOther Interview Questions

Design a timer circuit using VHDL which has the following: input : start_timer(ST) output: long_time(LT) short_time(ST) when the timer is triggered by the ST(either 0 or 1) signal the timer should generate two timing signals accordingly.While the long time is going ON the other should be OFF and vice versa.

1 Answers  


What is the coding about how to recognize color in fuzzy logic using Matlab R2009b?

1 Answers  


1.Explain what happens to a session object when the browser associated with it is closed? 2.Explain how a session object is created and used. (Note: you are not required to provide the Java statements such as ‘getAttribute’)

1 Answers  


How to get the version(major,minor,revision ) of VB6.0 delphi code .I am able to fetch dll file of vb6.0 but not vba file .Can u send me the code snippet in delphi to get the value for vb6.0.

1 Answers  


Write a program that implements a date class containing day, month and year as data members. Implement assignment operator and copy constructor in this class.

1 Answers  


Write a code snippet to display an integer in a binary format?

1 Answers  


Write code to make an object work like a 2-d array?

1 Answers  


Write code that allows to create only one instance of a class?

1 Answers  


How can you print an address of a variable?

1 Answers   TCS,


You have been asked to install a servlet engine (tomcat, glassfish, etc.) for a companies servlets. Assuming the company has an existing web/DBMS server (which may or may not be on the same server), explain in detail how would you implement the development project and a deployment solution.

1 Answers  


How can we write an algorithm for show max and min from two integer inputs ? without using if() , without any functions ...

1 Answers  


In LSMW , what does the following error mean and how to rectify it : Incorrect interface data for set 78 in method C . This error is occuring in idoc processing step of LSMW.

1 Answers   Wipro,


Categories