VOOZH about

URL: https://www.geeksforgeeks.org/quizzes/java-arraylist/

⇱ Quiz about Java ArrayList


Last Updated :
Discuss
Comments

Question 1

What is the default initial capacity of an ArrayList when it is created using the no-arg constructor?


  • 5

  • 10

  • 20

  • 1

Question 2

What will be the output of the following code?


  • [1, 3]


  • [2, 3]

  • [1, 2]

  • [1, 2, 3]

Question 3

Which method of ArrayList is used to add an element at a specific index?


  • addAtIndex()

  • insert()

  • add()

  • add(index, element)

Question 4

What will be the result of the following code?


  • [10, 20, 50, 40]


  • [10, 20, 30, 40]


  • [10, 20, 40, 50]

  • [50, 20, 30, 40]


Question 5

Which of the following methods is used to check if an ArrayList is empty?

  • isEmptyList()

  • isNull()

  • isEmpty()


  • empty()

Question 6

Which of the following methods returns the number of elements in an ArrayList?


  • size()

  • length()

  • count()


  • getSize()

Question 7

What is the time complexity of the add() method in an ArrayList (amortized case)?

  • O(1)


  • O(n)


  • O(log n)

  • O(n^2)

There are 7 questions to complete.

Take a part in the ongoing discussion