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?

Respuesta :

Answer:

Explanation: can you include a picture?

Answer:

Replace missing expression with:

keyboard[2][2].toLowerCase()+keyboard[1][0]+keyboard[0][4]

Explanation:

Given

The above code segment

Required

Which code displays "Cat"

First, we need to identify the location of C, a and t in the array

[tex]C \to keyboard[2][2][/tex] i.e. C is at the 2nd row index and 2nd column index

[tex]a \to keyboard[1][0][/tex] i.e. a is at the 1st row index and 0 column index

[tex]t \to keyboard[0][4][/tex] i.e. t is at the 0 row index and 4th column index

Next convert C to lowercase.

This is done using: toLowerCase() method.

So, we have: keyboard[2][2].toLowerCase()

Next, we concatenate each of the above.

i.e. keyboard[2][2].toLowerCase()+keyboard[1][0]+keyboard[0][4]

Lastly, the statement is printed:

System.out.println(keyboard[2][2].toLowerCase()+keyboard[1][0]+keyboard[0][4]);