ICSE Class 10 Computer Applications Question 28 of 30

Solved 2024 Specimen Paper ICSE Class 10 Computer Applications — Question 28

Back to all questions
28
Question

Question 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);
Answer
Output
20*23
Explanation

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.