Dear ladies and gents...
I have a newbie question about Java interfaces. I have not implemented any interfaces yet, so I do not know if what I am describing here could ever happen in "real life"...
Let's say I create a class that implements two interfaces that both have a method with the same signature. Furthermore, even though the methods have the same signature, they are supposed to carry out different functions. As a rather lousy hypothetical example:
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?
TIA
JJ
I have a newbie question about Java interfaces. I have not implemented any interfaces yet, so I do not know if what I am describing here could ever happen in "real life"...
Let's say I create a class that implements two interfaces that both have a method with the same signature. Furthermore, even though the methods have the same signature, they are supposed to carry out different functions. As a rather lousy hypothetical example:
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?
TIA
JJ