Back to questions
JuniorTheoryCommon
What does the program print?
public class Main {
public static void main(String[] args) {
System.out.println('a' + 'b');
}
}195
- Expecting
ab:+glues only when one side is aString; twocharvalues becomeint, and their codes 97 and 98 are added. - Expecting a compile error:
charis a 16-bit number type, so arithmetic on it is legal and gives anint.
- What does
"" + 'a' + 'b'print, and why? - How do you turn the code 98 back into the character
b?