1.

Which design pattern ensures that only one object of particular class gets created?(a) Singleton pattern(b) Filter pattern(c) State pattern(d) Bridge patternThis question was addressed to me during an interview.Query is from Design Patterns topic in section Java Beans & JDBC of Java

Answer»

Right answer is (a) Singleton pattern

To ELABORATE: Singleton pattern involves a single class which is responsible to create an object while making sure that only one object GETS created. This class provides a way to access the only object which can be accessed DIRECTLY without need to INSTANTIATE another object of the same class.



Discussion

No Comment Found

Related InterviewSolutions