Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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(){
if(instance == 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 thread-safe? Explain your answer?
What is the issue with this code?
rewrite the above code to make it better based on your answer in 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions