Java Interfaces in Java Interfaces in Java Interfaces Quiz

Fill in the blank to create an Array that can contain both Wine and Cheese:

public class Main {
    public static void main(String[] args) {
        Wine wine = new Wine();
        Cheese cheese = new Cheese();
        --Object[]--- foods = {wine, cheese};
    }
}

class Wine implements Drinkable, Delicious {
    //omitted
}

class Cheese extends Dairy implements Delicious {
    // omitted
}

3 Answers

Steven Parker
Steven Parker
177,727 Points

You're close, but instead of "Object", look at the other classes that both of these either extend or implement.
Do they have something in common?

Rafał Stasiak
Rafał Stasiak
3,762 Points

And what is correct answer?

Delicious[ ]

yige yang
yige yang
2,512 Points

why is Delicious[] working??? I tried other similar words, but they didn't work.

Steven Parker
Steven Parker
177,727 Points

Because that's the only thing implemented by both "Cheese" and "Wine".