Question 1
What is the output of the following program? ```java import java.io.BufferedReader; import java.io.StringReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new StringReader("one\ntwo")); System.out.println(br.readLine() + br.readLine() + br.readLine()); } } ```
A. one two null
readLine strips the line terminator and returns the bare content, so no spaces are introduced between the concatenated results.
B. onetwo
Stops after two reads, but a third readLine is called and returns null at end of stream, which is appended.
C. onetwonullCorrect answer
The first two calls return one and two (terminators stripped) and the third returns null at end of stream; concatenation yields onetwonull.
D. An EOFException is thrown by the third readLine
readLine signals end of stream by returning null, not by throwing; EOFException comes from data/object input streams, not BufferedReader.
Explanation
BufferedReader.readLine strips the line terminator and returns null once the end of the stream is reached, rather than throwing. Reading one, then two, then null and concatenating those three results produces onetwonull.