int[] a = {1, 2, 3, 4};
int t = a[0];
a[0] = a[3];
a[3] = t;What is the array after?
- Acheck_circle
{4, 2, 3, 1}
- B
{4, 4, 3, 1}
- C
{1, 2, 3, 4}
- D
{1, 4, 3, 4}
Explanation
Indices 0 and 3 are swapped using a temp variable.
AP Computer Science A· difficulty 2/5
int[] a = {1, 2, 3, 4};
int t = a[0];
a[0] = a[3];
a[3] = t;What is the array after?
{4, 2, 3, 1}
{4, 4, 3, 1}
{1, 2, 3, 4}
{1, 4, 3, 4}
Explanation
Indices 0 and 3 are swapped using a temp variable.
Want 10 more like this — adaptive to your weak spots?