adplus-dvertising
frame-decoration

Question

What is the difference between length() and size() of ArrayList?

a.

length() and size() return the same value

b.

length() is not defined in ArrayList

c.

size() is not defined in ArrayList

d.

length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list

Posted under Java Programming

Answer: (d).length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the difference between length() and size() of ArrayList?

Similar Questions

Discover Related MCQs

Q. Which class provides thread safe implementation of List?

Q. Which of the below is not an implementation of List interface?

Q. What is the worst case complexity of accessing an element in ArrayList?

Q. When an array is passed to a method, will the content of the array undergo changes with the actions carried within the function?

Q. What is the default clone of HashSet?

Q. Do we have get(Object o) method in HashSet.

Q. What does Collections.emptySet() return?

Q. What are the initial capacity and load factor of HashSet?

Q. What is the relation between hashset and hashmap?

Q. Set has contains(Object o) method.

Q. What is the difference between TreeSet and SortedSet?

Q. What happens if two threads simultaneously modify TreeSet?

Q. What is the unique feature of LinkedHashSet?

Q. Which of these standard collection classes implements a linked list data structure?

Q. Which of these classes implements Set interface?

Q. Which of these method is used to add an element to the start of a LinkedList object?

Q. Which of these method of HashSet class is used to add elements to its object?

Q. Which of these methods can be used to delete the last element in a LinkedList object?

Q. Which of this method is used to change an element in a LinkedList Object?

Q. Which of these object stores association between keys and values?