Java Programming
Accenture PrimermediumJava Programming4. Arrays And Strings

Accenture Java Programming Practice Question

Predict the output p class String_demo { public static void main(String args[]) { int ascii[] = { 65, 66, 67, 68}; String s = new String(ascii, 1, 3); System.out.println(s); } }

Answer options

A
ABCD
B
ABC
C
CDA
D
BCD An integer array is initialized with values 65, 66, 67 and 68. Its reference is "ascii". A new string object is initialized with this reference such that the elements from index 1 through 3 alone gets copied as "characters". This object is referred by "s". Printing this object will output BCD which are the char-equivalents of 66, 67 and 68.

Correct answer: ABCD

Explanation

Correct answer: ABCD.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

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