Question: The following code represents which design pattern? class Student { private static Student s; private Student () { } } public static Student getInstance()
The following code represents which design pattern? class Student { private static Student s; private Student () { } } public static Student getInstance() { if(s == null) { s = new Student (); } } return s; } class Main { public static void main(String[] args) { Student s; s= Student.getInstance(); class Main { public static void main(String[] args) { Student s; s= Student.getInstance(); } } Pick ONE option Singleton Design Pattern Factory Design Pattern Adapter Design Pattern Iterator Pattern Clear Selection
Step by Step Solution
3.51 Rating (174 Votes )
There are 3 Steps involved in it
Answer The code you provided is an implementation of the Sing... View full answer
Get step-by-step solutions from verified subject matter experts
