Predict the output of the following code snippet:

ICSE Class 10 Computer Applications PYQ · 2024 Specimen · Section A

2(viii)1 Mark · 2024 · Section A · 2024 Specimen

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.

← Previous questionNext question →

Share on WhatsApp

Browse the free Computer Applications sample bank