Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
easy Solved by 5 students

Iterating Through an Array of Objects

< Prev
Next >

An array of Product objects is declared as follows:

Product[] catalog = new Product[150];

Assume the catalog array has been initialized. The following code segment is intended to print the price of each Product in the array.

for (int i = 0; i < catalog.length; i++)
    /* line of code */

Which statement should replace /* line of code */ to correctly complete the code segment?

A

System.out.println(catalog.getPrice());

B

System.out.println(Product[i].getPrice());

C

System.out.println(i.getPrice());

D

System.out.println(catalog[i].getPrice());

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2singhris00011 0m 18s 82
#3psak1211 0m 33s 67
#4geethasailaja12 2m 09s -39
#5y.seong202702 1m 22s -102
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|FAQ