2(viii)
Predict the output of the following code snippet:
String a = "20"; String b = "23"; int p = Integer.parseInt(a); int q = Integer.parseInt(b); System.out.print(a + "*" + b);
Show SolutionHide Solution↓
20*23
Integer.parseInt() method will convert the strings a and b to their corresponding numerical integers — 20 and 23. In the statement, System.out.print(a + "*" + b); a, b, and "*" are strings so + operator concatenates them and prints 20*23 as the output.