🚀 Join 1,200+ candidates currently preparing with PrimerPrep
Java Programming
Accenture Technical PrimermediumJava Programming4. Arrays And Strings

Accenture Java Programming Practice Question

What will be the content of array variable table after executing the following code? public class Trial { public static void main(String[] args) { int []table[]=new int[5][5]; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { if(j == i) { table[i][j] = 1; System.out.print(table[i][j]); } else { table[i][j] = 0; System.out.print(table[i][j]); } } System.out.println("\n"); } } }

Answer options

A
100 010 001
B
Compilation error
C
111 111 111
D
000 000 000

Correct answer: 100 010 001

Explanation

Quick AnswerThe correct answer is 100 010 001 because it directly addresses the core logic of Java Programming.

The two-dimensional int array declaration is valid. The nested loop sets diagonal cells to 1 and other visited cells to 0, printing a 3x3 identity pattern.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!