Java Programming
primer-original-v2mediumJava Programming4. Arrays And Stringsprimer-original-v2

Java Programming Practice Question

class Output { public static void main(String args[]) { int a1[] = new int[10]; int a2[] = {1, 2, 3, 4, 5}; System.out.println(a1.length + " " + a2.length); } }

Answer options

A
10 5
B
5 10
C
0 10
D
0 5 Array a1 is created so as to contain 10 integer elements. Hence, the length is 10. Array a2 is initialized with 5 values. . Hence, the length is 5. y g

Correct answer: 10 5

Detailed Solution & Conceptual Analysis

This question has been retained as-is due to its unique context.

Key Engineering Takeaway

In Java Programming, understanding the underlying mechanics of Java Programming is critical for writing performant, bug-free production code and passing rigorous technical architecture reviews.

Related Java Programming questions

Practice more Java Programming questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.