Page 1 of 1
About Question enthuware.ocpjp.i.v11.2.3040 :
Posted: Fri Jul 03, 2020 11:31 am
by victor2016
Hi,
Should the first correct option for Location 3 be 'public void switchOn()' instead of 'public void reset()' since switchOn() is method in Device interface?
I also ran a test program and it doesn't compile without abstract interface method being implemented in the class that implements the interface.
Thanks,
Victor.
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
Posted: Fri Jul 03, 2020 1:35 pm
by admin
But switchOn is already implemented by Router. So, MimoRouter doesn't need to implement it (because MimoRouter extends Router.)
You need to try the code exactly as given in the problem statement.
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
Posted: Fri Jul 03, 2020 5:53 pm
by victor2016
Thank you for clarifying. I am puzzled why Router class is not stating that it's implementing Device though. I ran code exactly as in the question and it compiles fine with and without "implements Device" at Location 1.
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
Posted: Fri Jul 03, 2020 9:25 pm
by admin
Why do you think any class must implement an interface?
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
Posted: Sun Jul 05, 2020 10:07 am
by victor2016
There is switchOn() in Router class and switchOn() in Device interface and a placeholder location 1. This leads me to think it's part of a question requirements for Router class to implement Device interface. And since it is MimoRouter that's implementing Device it leads me to think switchOn() should be implemented by MimoRouter. What am I missing?
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
Posted: Sun Jul 05, 2020 10:27 pm
by admin
Yes, logically it makes sense for Router to implement Device. But there is no such technical requirement imposed by Java. It might be a "business" requirement but a business requirement cannot be imposed by Java.
MiMo says it implements Device and so, it is required by Java to have switchOn() method (or declare itself as abstract). In this case, MiMoRouter does have a switchOn method (because of inheritiance). So, there is no problem.
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
Posted: Mon Jul 06, 2020 9:29 am
by victor2016
Thank you
