Q&A ICSE2014-03J #7420
Question:
What will be the output when the following code segments are executed?
(i)
String s = "1001";
int x = Integer.valueOf(s);
double y = Double.valueOf(s);
System.out.println("x=" +x);
System.out.println("y=" +y);
(ii)Β System.out.println(“The King said \”Begin at the beginning!\” to me.”);
Answer:
(i) s = Βg1001ΒΒ
x = 1001
y = 1001.0
Output will be
x=1001
2 y=1001
(ii) The King said βBegin at the beginning!β to me.
\β is an escape sequence which prints β
