About Question enthuware.ocpjp.i.v11.2.3040 :
Moderator: admin
-
- Posts: 18
- Joined: Wed Jan 20, 2016 7:16 pm
- Contact:
About Question enthuware.ocpjp.i.v11.2.3040 :
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.
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.
-
- Site Admin
- Posts: 10061
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
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.
You need to try the code exactly as given in the problem statement.
If you like our products and services, please help us by posting your review here.
-
- Posts: 18
- Joined: Wed Jan 20, 2016 7:16 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
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.
-
- Site Admin
- Posts: 10061
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
Why do you think any class must implement an interface?
If you like our products and services, please help us by posting your review here.
-
- Posts: 18
- Joined: Wed Jan 20, 2016 7:16 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
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?
-
- Site Admin
- Posts: 10061
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3040 :
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.
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 18
- Joined: Wed Jan 20, 2016 7:16 pm
- Contact:
Who is online
Users browsing this forum: gadsgadsx and 120 guests