Quick Print – Computer Sir Ki Class

Solved Problem Solved Problem#JAVA#7246

## Problem Statement - Output Writing – Using integer wrapper

Give the output of the following code:

String A =”26″, B=”100″;
String D=A+B+”200″;
int x= Integer.parseInt(A);
int y = Integer.parseInt(B);
int d = x+y;
System.out.println(“Result 1 = “+D);
System.out.println(“Result 2 = ” +d);

## Solution

```		class Test
{
public static void main(String[] args)
{
String A ="26", B="100";
String D=A+B+"200";
int x= Integer.parseInt(A);
int y = Integer.parseInt(B);
int d = x+y;
System.out.println("Result 1 = "+D);
System.out.println("Result 2 = " +d);
}
} ```

## Run Output

``````Result 1 = 26100200
Result 2 = 126``````

String A= “26”, B= “100”; //numbers being initialised in string form
String D=A+B+ “200”;
D = “26” + “100” + “200” = “26100200”   //being the concatenation of strings
int x= Integer.parseInt(A);
x will contain 26 as number.
int y=Integer.parseInt(B);
y will contain 100 as number
int d=x+y;
d would be  26 + 100 = 126
System.out.println(“Result 1=” +D);
D would be 26100200
System.out.println(“Result 2 = ” +d);
d would be 126

Ans.
Result 1=26100200
Result 2=126