✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Considera la següent funció getInstance
que retorna la mateixa instància d'un objecte cada vegada que es crida:
Per provar que el mètode getInstance
retorna sempre la mateixa instància, quin mètode d'assertion hauríem d'utilitzar?
public class Singleton { public static Singleton instance; private Singleton() {} public static Singleton getInstance() { if (instance == null) { instance = new Singleton(); } return instance; }} |
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!