Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 52

You want to create a singleton class by using the Singleton design pattern.

Which two statements enforce the singleton nature of the design? (Choose two.)

    Correct Answer: B, F

    To enforce the singleton nature of a design, the constructor of the class should be made private to prevent instantiation from outside the class. Additionally, the single instance of the class should be made static and final to ensure that exactly one instance of the class is created and it is globally accessible. These steps ensure that the singleton pattern is correctly implemented and adhered to.

Discussion
samtash1034Options: BD

B and D

AVB22Options: BF

B and F

asdfjhfgjuaDCVOptions: BF

bf are correct

steefaandOptions: BF

B and F are correct.

Kim514Options: BF

Answer is B, F. Eager initialization. https://www.digitalocean.com/community/tutorials/java-singleton-design-pattern-best-practices-examples

r1muka5Options: BF

I think the answers are B and F here

WilsonKKerllOptions: BD

Answer is B, D. If D. Use a public reference to point to the single instance. change public to static.

WilsonKKerllOptions: BF

Answer is B, F.