String Objects: Concatenation, Literals, and More

AP Computer Science A· difficulty 4/5

char c = 'X';
int n = c + c;
System.out.println(n);

What is printed?

  • A

    88

  • B

    XX

  • C

    176

    check_circle
  • D

    Error

Explanation

Without a string operand, char + char promotes to int arithmetic; 'X' is 88, so 88 + 88 = 176.

Want 10 more like this — adaptive to your weak spots?

Related questions