About Question enthuware.ocpjp.v7.2.1105 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ThufirHawat
Posts: 28
Joined: Wed Feb 25, 2015 9:03 am
Contact:

About Question enthuware.ocpjp.v7.2.1105 :

Post by ThufirHawat »

Here in this question, as well explained:
1. Make the constructor of the class private so that no one can instantiate it except this class itself.
2. Add a private static variable of the same class to the class and instantiate it.
3. Add a public static method (usually named getInstance()), that returns the class member created in step 2.
The number 2 "Add a private static...", this is not present on the code. So, the answer "Add a static method that returns an instance of SpeedSensor." will not be correct because, every time you will call this method, a new instance will be created and delivered to the client.

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1105 :

Post by admin »

The variable in 2 is not there that is why it is asking you to add the variable. So I am not sure I understand you question?
Why do you think every time you will call this method, a new instance will be created and delivered to the client?

ThufirHawat
Posts: 28
Joined: Wed Feb 25, 2015 9:03 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1105 :

Post by ThufirHawat »

Sir, can you please show me where "it is asking you to add the variable"?

I think every time I call this method, a new Instance will be returned, since there is no instance variable to store this instance, and this method only will be possible returning a new Instance(); every time.

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1105 :

Post by admin »

Ok, I see the confusion. The options do not contain all the changes that are required. You are right that as such the problem statement implies that if you select correct options, Singleton pattern will be implemented.
I have updated the question statement to reflect that.

thank you for your feedback!
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests