C and D are correct since we need static method to return instance of singleton and private constructor so that it is not possible to create multiple instances.
Considering the standard Singleton implementation (i.e. the Bill Pugh implementation) :
public class BillPughSingleton {
private BillPughSingleton(){}
private static class SingletonHelper{
private static final BillPughSingleton INSTANCE = new BillPughSingleton();
}
public static BillPughSingleton getInstance(){
return SingletonHelper.INSTANCE;
}
}
We can conclude that answer is CD
it is BD because constructor has to be private to prevent instantiation and also there must be a method to check if there is already an object of it to provide otherwise create a new one.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
JME_CHG
Highly Voted 3 years, 10 months agovidhuharu
Most Recent 3 months, 1 week agosteefaand
11 months, 2 weeks agolchowen
2 years, 3 months agokarta
2 years, 5 months agoOhayou
2 years, 10 months agoWilsonKKerll
2 years, 10 months agomevlt
2 years, 10 months agopetetsai
3 years agoSvetleto13
3 years, 8 months ago