Ask Question
3 May, 01:14

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› ()

+3
Answers (1)
  1. 3 May, 04:26
    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?
Find an answer to your question ✅ “Which of the following does not correctly declare an ArrayList? a. ArrayList‹ Integer› list = new ArrayList‹ ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers