Page 1 of 1

About Question enthuware.ocpjp.v7.2.1105 :

Posted: Tue Jun 02, 2015 10:55 pm
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.

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

Posted: Wed Jun 03, 2015 5:13 am
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?

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

Posted: Thu Jun 04, 2015 11:41 pm
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.

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

Posted: Fri Jun 05, 2015 5:40 am
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.