Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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
231,269 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?

Delicious[ ]

yige yang
yige yang
8,329 Points

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

Steven Parker
Steven Parker
231,269 Points

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