Question: Answer below questions about the Singleton: ( 2 points ) One of the limitations of Singleton is sub classing any class can subclass the Singleton
Answer below questions about the Singleton:
points One of the limitations of Singleton is sub classing any class can subclass the Singleton class and thus have access to its own instance because of inheritance sub class inherit the parent class, what do you think of this?
Consider the following code to answer the following question:
public class PrintDriver
private static final PrintDriver INSTANCE new PrintDriver;
private PrintDriver
public static PrintDriver getInstance return INSTANCE;
which type of initialization is used in the code? What is issue of this type of initialization?
Is the singleton in the above code threadsafe? Explain your answer?
Rewrite the code to make it threadsafe using doublecheck locking?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
