package Test2016;import java.util.ArrayList;import java.util.List;public class Test2016 { public static void main(String[] args) { List first = new ArrayList(); //Fruit -> Apple first.add(new Apple()); first.add(new Fruit()); first.add(new RedApple()); // first.add(new Food()); //error System.out.println(first.get(0)); System.out.println(first.get(1)); List second = new ArrayList (); second.add(null); } }class Food {}class Fruit extends Food {}class Apple extends Fruit {}class RedApple extends Apple {}