You can declare a variable that is typed by an interface:
... RatingInterface x; ...
The value of such a variable can be an instance of any class that
implements the interface. For example, if both the Movie
class and
the Symphony
class implement the RatingInterface
interface, you can write the following:
... x = new Movie(); ... x = new Symphony(); ...