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

Consider the following code segment. Which statement, when used to replace // Missing Code, will correctly store the number of elements in the ArrayList in the size 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
        System.out.println("Size: " + size);
    }
}
A

int size = list.getSize();

B

int size = list.size();

C

int size = list.length;

D

int size = list.size;

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1geethasailaja22 0m 35s 165
#2kaisuki12 0m 00s 90
#3bommasam00011 0m 12s 88
#4singhris00011 0m 12s 88
#5y.seong202712 34m 02s -1,952
Items per page:
10
1 – 5 of 5
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy