Question 1
What does this print? ```java public class Main { public static void main(String[] args) { String s = """ foo\ bar baz"""; System.out.println(s.replace("\n", "|")); } } ```
A. foo|bar|baz
Treats the trailing backslash as a normal character and keeps the newline it was meant to remove.
B. foobarbaz
Removes BOTH newlines; only the one after the backslash-continued line is suppressed.
C. foo\bar|baz
Keeps the backslash in the value; the continuation escape is consumed and never appears in the string.
D. foobar|bazCorrect answer
The trailing backslash after foo is the line-continuation escape: it deletes that line terminator, joining foo and bar into foobar; the newline after bar is ordinary content and baz shares its line with the closing delimiter, so replacing \n with | prints foobar|baz.
Explanation
A backslash at the end of a line inside a text block is the line-continuation escape: it suppresses exactly one line terminator and leaves no character behind, so foo and bar merge into foobar. The remaining newline after bar is ordinary content, and baz shares its line with the closing delimiter, so no further newline follows. Replacing the single remaining newline with a pipe yields foobar|baz.