Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSA Question of the Day March 6, 2025

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    Given:

    Armor.java

    public class Armor extends Item {
        public void use() {/* Implementation not shown */}
    }
    Java

    Key.java

    public class Key extends Item {
        public void use() {/* Implementation not shown */}
    }
    Java

    Potion.java

    public class Potion extends Item {
        public void use() {/* Implementation not shown */}
    }
    Java

    Item.java

    public class Item {  
        public Item() {/* Implementation not shown */}  
    }
    Java

    Main.java

    import java.util.ArrayList;
    
    public class Main
    {
        public static void main(String[] args)
        {
            ArrayList<Item> items = new ArrayList<Item>();
            items.add(new Armor());
            items.add(new Key());
            items.add(new Potion());
    
            for (Item item : items) 
            { 
                item.use();
            }
        }
    }
    Java

    What will this program do?