How to create an instance of a class if the class has
private constructor?
Answer Posted / eswar
u can create instance like this...
class Ex
{
public static Ex e=null;
private Ex()
{}
public Ex getObj()
{
if(e==null)
e=new Ex();
return e;
}
}
Actually the above coding is example for singleton Java
class.... which creates omly one object per JVM
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
Explain features of interfaces in java?
What is composition in java?
What is a method signature java?
how to prepare for IT Officers Interview in Banks
What is the purpose of using break in each case of switch statement?
Which software is used for java programming?
Is java call by reference?
Write a program to check string is palindrome without using loop?
What class allows you to read objects directly from a stream in java programming?
Is 9 a prime number?
How are this() and super() used with constructors in java programming?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?
Is array a class?
Is a boolean variable?
Explain heap sort?