Output Questions for Class 10 ICSE Computer Applications
Predict the output of the following Java program snippet:
String n1 = "46", n2 = "64";
int total = Integer.parseInt(n1) + Integer.parseInt(n2);
System.out.println("The sum of " + "46 " + "and" + " 64" + " is " + total);
Java
Java String Handling
51 Likes
Answer
The sum of 46 and 64 is 110
Working
Integer.parseInt() method will convert the strings n1 and n2 to their corresponding numerical integers. So, 46 and 64 are added as numerical values and the result 110 is stored in int variable total.
Answered By
28 Likes