Question: Consider the following code on Singleton to answer below questions: public class Driver { private static Driver instance; private Driver ( ) { } public
Consider the following code on Singleton to answer below questions:
public class Driver
private static Driver instance;
private Driver
public static synchronized Driver getInstance
ifinstance null instance new Driver;
return instance;
Which OO basics is used by the Singleton pattern, justify your answer?
Can we consider the instance of Driver in the above code threadsafe? Explain your answer?
What is the issue with this code?
rewrite the above code to make it better based on your answer in
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
