+1 vote
in Data Structures & Algorithms I by (110k points)
Which of the following is the correct syntax to declare an ArrayList in Java?

(a) ArrayList al = new ArrayList();

(b) ArrayList al = new ArrayList[];

(c) ArrayList al() = new ArrayList();

(d) ArrayList al[] = new ArrayList[];

Question is taken from Dynamic Array in section Arrays Types of Data Structures & Algorithms I

I have been asked this question in an internship interview.

1 Answer

+1 vote
by (408k points)
selected by
Best answer
The correct option is (a) ArrayList al = new ArrayList();

For explanation: This is a non-generic way of creating an ArrayList.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.