Accenture Primer
Accenture DumpmediumAccenture PrimerAccenture-Primer-Dump

Accenture Accenture Primer Practice Question

Predict the output What will be the output for the given code snippet startprogram Public class Main{ public static void main(String args[]) { int arr[] = new int[] {0,1,2,3,4,5,6,7,8,9}; int n=6; n = arr[arr[n] / 2]; System.out.println(arr[n] / 2); } } endprogram

Answer options

A
2
B
1
C
6
D
0

Correct answer: 1

Explanation

arr={0..9}, n=6. Step 1: n = arr[arr[6]/2] = arr[6/2] = arr[3] = 3. Step 2: System.out.println(arr[3]/2) = 3/2 = 1 (integer division).

Related Accenture Accenture Primer questions

Practice more Accenture Accenture Primer questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.