How to prevent to create multiple objects of a java class?

Answers were Sorted based on User's Feedback



How to prevent to create multiple objects of a java class?..

Answer / sadiq

Using Singleton Design pattern we can prevent class creating
multiple objects.

Is This Answer Correct ?    30 Yes 3 No

How to prevent to create multiple objects of a java class?..

Answer / naseer

declare constructor as private .that class only create one object

Is This Answer Correct ?    10 Yes 6 No

How to prevent to create multiple objects of a java class?..

Answer / zoozoo

use collections

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Core Java Interview Questions

What is class??

0 Answers   Tech Mahindra,


Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?

0 Answers  


Which types of exceptions are caught at compile time?

0 Answers  


What is difference between checked and unchecked exception in java?

0 Answers  


What is the root class for all Java classes?

8 Answers   IBM, Infosys,






how to get the max salary and name of employee from arraylist without using the Comperator or even Comparable interface?

2 Answers  


Why java strings are immutable in nature?

0 Answers  


What does int argc char * argv [] mean?

0 Answers  


can you program for reverse string?

7 Answers   IBM,


What is Gang of four design patterns

0 Answers   Infosys,


What is empty string literal in java?

0 Answers  


What is double data type?

0 Answers  


Categories