Java Programming
Accenture Technical PrimermediumJava Programming4. Arrays And Strings

Accenture Java Programming Practice Question

class TestArray { public static void main(String args[]) { int arr_sample[] = new int[2]; System.out.println(arr_sample[0]); } } What will be the result of compiling and executing the above code?

Answer options

A
The program compiles and prints 1 when execute
B
The program compiles and runs but the results are not predictable because of un-initialized memory being rea
C
The program generates a runtime exception because arr_sample[0] is being read before being initialize
D
The program compiles and prints 0 when execute
E
The program does not compile because arr_sample[0] is being read before being initialize

Correct answer: The program compiles and prints 1 when execute

Explanation

Quick AnswerThe correct answer is The program compiles and prints 1 when execute because it directly addresses the core logic of Java Programming.

Correct answer: The program compiles and prints 1 when execute.

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!