| preferred AP College board partner for AP classes
AP Computer Science A/Unit 7: ArrayList
Start Practice Test
Share
easy Solved by 5 students
ArrayList Size Method
< Prev
Next >

Which of the following code snippets correctly fills in the missing code to store the size of the ArrayList in a variable?

import java.util.ArrayList;
public class Test {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        list.add("Alpha");
        list.add("Beta");
        // Missing Code: print the size of list.
        System.out.println("Size: " + size);
    }
}
A

int size = list.length;

B

int size = list.getSize();

C

int size = list.size();

D

int size = list.size;

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1geethasailaja22 0m 35s 165
#2kaisuki12 0m 00s 90
#3singhris00011 0m 12s 88
#4y.seong202712 34m 02s -1,952
APFIVE © 2020.
Email: [email protected]|Privacy Policy