Question 1
What is the output of the following program? ```java public class Main { public static void main(String[] args) { char a = 'a'; char b = 'b'; System.out.println(a + b + "" + (char) (a + 1)); } } ```
A. abb
This treats a + b as joining two characters; before any String operand appears, + on chars is numeric addition.
B. ab195
This has the order backwards — the char addition happens before the empty string and is numeric, and concatenation only takes over after it.
C. 195bCorrect answer
Before the empty string a + b is numeric (97 + 98 = 195); after it concatenation takes over, and (char)(97 + 1) is 'b', giving "195b" (JLS 8 §5.6.2, §15.18.1).
D. 195a
The numeric part is right, but the cast applies to a + 1 = 98, which is 'b', not the original 'a'.
Explanation
Before the empty string, a + b is NUMERIC: 97 + 98 = 195. After it, concatenation takes over, and (char)(97 + 1) is 'b'. "195" + "b" = "195b". Position relative to the first String decides char arithmetic vs text.