| preferred AP College board partner for AP classes
AP Computer Science A/Unit 7: ArrayList
Start Practice Test
Share
medium Solved by 7 students
Initializing Array Elements With Loops
< Prev
Next >

An array books has been declared to store Book objects. Which of the following code segments correctly initializes each element of the books array with a new Book object?

I.

for (Book b : books)
    b = new Book();

II.

for (int i = 0; i < books.length; i++)
    books[i] = new Book();

III.

for (Book b : books)
    books[b] = new Book();
A

III only

B

II only

C

I and II only

D

I, II, and III

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1ravi.palepu22 0m 42s 158
#2kaisuki12 0m 00s 90
#3singh.advik1311 2m 07s -27
#4geethasailaja14 2m 06s -56
#5y.seong202723 4m 37s -87
#6singhris00014 5m 24s -254
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy