Multiple choice

How many constructors are there of ArrayList class in Java?

  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is the correct answer as there are 3 constructors of ArrayList class in Java Collections, viz. ArrayList(): creates an empty constructor with default initial capacity; ArrayList(c : collection): creates an arraylist from existing collection c; and ArrayList(x int): creates an arraylist with initial capacity x. So, this is the correct answer.