Java Programming Practice Question
Predict the output class String_demo { public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); System.out.println(s); } }Answer options
A
a
B
b
C
abc
D
c A character array is initialized with 'a', 'b' and 'c' and the array reference is chars. Printing this reference will output ab
E
A "new" string object is initialized with this reference and this object is referred by "s". Printing this reference will output ab
Correct answer: a
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.