Computer Applications

The output of the statement:

System.out.println(Character.toUpperCase('b') + 2); is:

  1. 66
  2. 100
  3. 68
  4. 98

Java Library Classes

5 Likes

Answer

68

Reason — The method Character.toUpperCase('b') converts 'b' to 'B'. In Java, when a character is used in an arithmetic expression, it is converted to its ASCII (Unicode) value. The ASCII value of 'B' is 66, and adding 2 gives 66 + 2 = 68. Hence, the output is 68.

Answered By

2 Likes


Related Questions