Ask Question
19 May, 18:42

Which of the following does not correctly declare an ArrayList?

a. ArrayList‹ Integer› list = new ArrayList‹ Integer› (10)

b. ArrayList‹ Integer› = new ArrayList‹ Integer› (10)

c. ArrayList‹ Integer› list = new ArrayList‹ Integer› ()

+1
Answers (1)
  1. 19 May, 21:44
    0
    Option b. ArrayList‹ Integer› = new ArrayList‹ Integer› (10) does not correctly declare an ArrayList.

    Explanation:

    ArrayList in Java dynamically stores elements in it. It also called as re - sizeable array as it expands in size when elements are added and decreases when an element is removed from it. This array list class also allows to use duplicate and null values.

    The syntax for creating Array list is as follows

    ArrayList obj = new ArrayList ()

    Type specifies the type of ArrayList like Integer, Character, Boolean etc, and obj is the object name. But in the option b ArrayList‹ Integer› = new ArrayList‹ Integer› (10) object name is missed and not specified.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Which of the following does not correctly declare an ArrayList? a. ArrayList‹ Integer› list = new ArrayList‹ ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers