1.

Which of these method can be used to increase the capacity of ArrayList object manually?(a) Capacity()(b) increaseCapacity()(c) increasecapacity()(d) ensureCapacity()I have been asked this question during an interview.This intriguing question originated from Java.util in division java.util – The Collections Framework of Java

Answer»

Right option is (d) ensureCapacity()

To elaborate: When we add an element, the capacity of ArrayList OBJECT increases automatically, but we can INCREASE it manually to SPECIFIED length X by using FUNCTION ensureCapacity(x);



Discussion

No Comment Found

Related InterviewSolutions