Array Indexing with Post-Increment
What is printed as a result of executing the following code segment?
public class IncrementArray {
public static void main(String[] args) {
int[] values = {2, 4, 6, 8};
int i = 0;
int result = values[i++] + values[i++] * 2;
System.out.println(result);
}
}
A
10
B
14
C
12
D
16
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | winstonhou1107 | 2 | 2 | 1m 06s | 134 |
| #2 | kazvin.tjakradinata | 1 | 3 | 2m 00s | -40 |
| #3 | midnightasdark | 1 | 3 | 2m 24s | -64 |
| #4 | Pelisx | 0 | 1 | 1m 02s | -72 |
| #5 | theofanusmischa | 0 | 1 | 1m 07s | -77 |
| #6 | tellabhinaya | 0 | 1 | 1m 43s | -113 |
| #7 | suhanakochhar006 | 1 | 1 | 3m 55s | -135 |
| #8 | bommasam000 | 3 | 3 | 7m 35s | -155 |
| #9 | singhris000 | 0 | 3 | 2m 26s | -176 |
| #10 | sathilak000 | 1 | 4 | 5m 16s | -246 |
Items per page:
10
1 – 10 of 13
APFIVE