Java Programming
Accenture PrimermediumJava Programming4. Arrays And Strings

Accenture Java Programming Practice Question

Determine the output: class Evaluate { 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); } }

Answer options

A
0
B
1
C
3
D
6 arr is an integer array that is initialized with 10 values. When n is initialized with value 6, n = arr[arr[n] / 2] evaluates to n = 3. Now, printing arr[n] / 2 will output 1.

Correct answer: 1

Explanation

Correct answer: 1.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

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