✏️ Explanatory Question

State the data type and value of res after the following is executed:

char ch='t';
res= Character.toUpperCase(ch);

👁 98 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

Data type of res is char and its value is T.

  1. Data Type of res:

    • The Character.toUpperCase(ch) method returns a char type. Hence, the data type of res will be char.

  2. Value of res:

    • The Character.toUpperCase(ch) method converts the character ch to its uppercase equivalent. In this case, 't' is converted to 'T'.

    • So, the value of res will be 'T'.

In summary:

  • Data Type: char

  • Value: 'T'