ICSE Class 10 Computer Applications
Question 14 of 30
Solved Sample Paper 2 — Question 14
Back to all questions 14
Question Question 1(xiv)
Identify the output of the following code :
String P = "20", Q = "19";
int a = Integer.parseInt(P);
int b = Integer.valueOf(Q);
System.out.println(a + "" + b);- 2019
- 39
- 20
- 19
2019
Reason — In the given code, first strings P and Q are converted to their corresponding integer values. So a becomes 20 and b is 19. In the statement System.out.println(a + "" + b); the expression a + "" performs string concatenation as one of the operands of + operator is a string (empty string ""). As a result, the integer value a is converted to a string. It is then concatenated with variable b to give the output as 2019.