0%
0 / 15 answered

Wrapper Classes Practice Test

15 Questions
Question
1 / 15
Q1

In the given program, an ArrayList stores objects, so scores use Integer wrappers instead of primitive int values.


import java.util.ArrayList;

public class ScoreTracker {

    public static void main(String[] args) {

        ArrayList<Integer> scores = new ArrayList<>();

        // Wrapper objects can be stored; primitives cannot be generic types

        scores.add(11);

        scores.add(22);

        System.out.println(scores);

    }

}

What is the purpose of using wrapper classes in this scenario?

Question Navigator