What is singleton class?
Answer Posted / vimal eldose george
Singleton gives only one instance.
class Single{
static int objCreated = 0;
private Single(){
}
public static Single getThis(){
if(objCreated==0)
{
return new Single();
ob=1;
}else
{
return this;
}
}
}
Is This Answer Correct ? | 32 Yes | 17 No |
Post New Answer View All Answers
2) Suppose there are 5 directories having lot of files (say txt files) in each directory. 2 things :- 2.1) You want to search for filenames which have a particular pattern. 2.2) Out of these filtered files you want to search for a particular keyword or a search string. How can you achieve this?
What is a numeric literal?
Explain some best practices you would apply while using collection in java?
How java uses the string and stringbuffer classes?
Why we use protected in java?
What is comparable and comparator interface? List their differences
What is the size of an array?
Can a class be a super class and a sub-class at the same time? Give example.
Why are there no global variables in java?
What is collection class in java?
What is the r character?
What is java volatile?
Why is string buffer better than string ?
what is synchronization and why is it important? : Java thread
How concurrent hashmap works?