Question: Please answer question. Will give thumps up! Consider the following class: import java.text. SimpleDateFormat; import java. util. Date; public class Assignment3 { public Assignment3() SimpleDateFormat


Please answer question. Will give thumps up!
Consider the following class: import java.text. SimpleDateFormat; import java. util. Date; public class Assignment3 \{ public Assignment3() SimpleDateFormat dateFormat = new SimpleDateFormat("H:m:ss: S"); String formattedDate = dateFormat. format(new Date()); System. out.print("Instance created at:" + formattedDate); We would like to implement the class as a modified version of the Singleton design pattern. We will create two new classes, and , which implement both the lazy and eager Singleton design patterns. Each of these classes will hold a maximum of three instances instead of one. Below is the client test code that creates three instances of each Singleton pattern, with a twosecond pause between each creation. This demonstrates the difference in instance creation time. The output of the client code execution is given below. You'll get a similar output with different timestamps. This output displays the difference in instance creation time between the Lazy and Eager approaches. Creating three instances of Lazy Singleton... Instance created at: 6:49:09:38 Instance created at: 6:49:11:49 Instance created at: 6:49:13:56 Creating three instances of Eager Singleton... Instance created at: 6:49:13:60 Instance created at: 6:49:13:60 Instance created at: 6:49:13:60 Copy the class into your project. Then, implement the and classes. [ Check the client code and note that the method takes a unique number parameter to indicate which instance should be returned. Place your source codes in the Q1 folder
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
