457,810 views
8 votes
8 votes
NO LINKS: Consider the following code segment, which is intended to display "cat".

String[][] keyboard = {{"q", "w", "e", "r", "t"},

{"a", "s", "d", "f", "g"},

{"z", "x", "c", "v", "b"}};

System.out.println(/* missing expression */);

Which of the following can replace /* missing expression */ so that the code segment works as intended?

A) keyboard[12] + keyboard[5] + keyboard[4]

B)keyboard[13] + keyboard[6] + keyboard[5]

C)keyboard[2][2] + keyboard[1][0] + keyboard[0][4]

D)keyboard[2][2] + keyboard[0][1] + keyboard[4][0]

E)keyboard[3][3] + keyboard[2][1] + keyboard[1][5]

User JoshG
by
2.5k points

1 Answer

9 votes
9 votes

Answer: C) keyboard[2][2] + keyboard[1][0] + keyboard[0][4]

Explanation: Since Java starts the count at 0 rather than 1, "c" is located on row 2 and column 2, "a" is located on row 1 and column 0, and "t" is located on row 0 and column 4. Thus, the answer is C.

User Wenbin Geng
by
3.1k points