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.)
A.
Make the class static.
B.
Make the constructor private.
C.
Override equals() and hashCode() methods of the java.lang.Object class.
D.
Use a public reference to point to the single instance.
E.
Implement the Serializable interface.
F.
Make the single instance created static and final.
B. Make the constructor private.
Explanation: To ensure that a Singleton class has only one instance, its constructor should be private. This prevents anyone from creating new instances of the class from outside.
F. Make the single instance created static and final.
Explanation: To ensure that there is only one instance of a Singleton class, that instance should be declared as static and final. static means that the instance is shared by all objects of the class, and final means that it cannot be changed after it is created.
This section is not available anymore. Please use the main Exam Page.1z0-809 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
6c84cb9
7 months, 4 weeks ago6c84cb9
9 months, 1 week agoasdfjhfgjuaDCV
1 year, 2 months agosteefaand
1 year, 3 months agoKim514
2 years, 1 month agor1muka5
2 years, 1 month agoWilsonKKerll
3 years, 1 month agoWilsonKKerll
3 years, 2 months agosamtash1034
3 years, 4 months agoAVB22
3 years, 6 months ago