Re: Implementing two interface methods with same signature
- From: Bryce <spamtrap@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 07 Oct 2005 13:27:38 -0400
On 6 Oct 2005 23:10:08 -0700, "jjoensuu" <j_joensuu@xxxxxxxxx> wrote:
>interface VacationSpots {
> //return true if location is a resort
> boolean resort();
>}
>
>interface SortRooms {
> //return true once rooms are sorted
> boolean resort();
>}
>
>public class Resort implements VacationSpots, SortRooms {
> //other code
> boolean isResort;
> //other code (constructor etc)
> public boolean resort(){
> return isResort;
> }
> //other code
>}
>
>QUESTION: In this sort of a case, which "resort" method is actually
>implemented?
Does it really matter? All an interface does is define a set of
methods that any implementing classes must implement. Its a contract
with an implementing class,.
Using your example, the both would be valid and would result in
calling the same method:
VacationSpots spot = new Resort();
spot.resort();
and
SortRooms rooms = new Resort();
rooms.resort();
So, in effect, it doesn't matter who's resort method it is.
--
now with more cowbell
.
- Follow-Ups:
- Re: Implementing two interface methods with same signature
- From: HalcyonWild
- Re: Implementing two interface methods with same signature
- From: Thomas Hawtin
- Re: Implementing two interface methods with same signature
- References:
- Implementing two interface methods with same signature
- From: jjoensuu
- Implementing two interface methods with same signature
- Prev by Date: Re: Auto Populate POJO - Anyone know of any libraries that can do this?
- Next by Date: Re: Time to ditch "SSCCE"?
- Previous by thread: Re: Implementing two interface methods with same signature
- Next by thread: Re: Implementing two interface methods with same signature
- Index(es):