Capgemini Interview Question
Senior Software Development EngineersCountry: India
Interview Type: In-Person
The class can contain a static list of the weak-references of all the objects instantiated for the class. Whenever a function which modifies the state is called for an object, the object can call a corresponding static function in the class, which in turn, can call the same function for all the other existing (not garbage collected) objects for that class.
TextBox class can implement Cloneable interface. By default the clone method will do shallow copy of the given object. The "textbox" could be String member of another referenced class.
So, the solution goes like this. Every TextBox class object are cloned to each other. And as cloning provides shallow copy, the same referenced class object is shared amongst all the cloned TextBox class object.
Singleton Pattern.
- Anoop December 30, 2015