Iterating Through an Array of Objects
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[i].getPrice());
B
System.out.println(catalog.getPrice());
C
System.out.println(i.getPrice());
D
System.out.println(Product[i].getPrice());
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | singhris000 | 1 | 1 | 0m 18s | 82 |
| #3 | psak12 | 1 | 1 | 0m 33s | 67 |
| #4 | geethasailaja | 1 | 2 | 2m 09s | -39 |
| #5 | y.seong2027 | 0 | 2 | 1m 22s | -102 |
Items per page:
10
1 – 5 of 5
APFIVE