Computer Science, asked by mansuraahmed01, 19 days ago

String A = “26” , B = “100”;

String D = A + B + “200”;

Int x = Integer.parseInt(A);

Int y = Integer.parseInt(B);

Int d = x + y ;

pln(D);

pln(d);​

Answers

Answered by amaheswarakarthikeya
0

Answer:

String A = “26” , B = “100”;

String D = A + B + “200”;

Int x = Integer.parseInt(A);

Int y = Integer.parseInt(B);

Int d = x + y ;

pln(D);

pln(d);

Answered by BrainlyProgrammer
2

Corrected Question:-

  • Predict the output

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(D);

System.out.println(d);

Given:-

  • A="26"
  • B="100"

D=A+B+"200";

Here A and B are string variable even if they are storing numbers so instead of getting added, it will get concatenated.

D="26"+"100"+"200"

= "26100200"

//Strings get concatenated, numbers (in data types : short, int, float, long, double) are added

int x= Integer.parseInt(A);

int y= Integer.parseInt(B);

Integer.parseInt() converts string to integer

so x and y storing integer number of A and B

so x and y is 26 and 100 respectively but in integer data type.

d=x+y

= 26+100

= 126

  • Remember:- Java is case-sensitive language so d and D are different.

Output:-

Result 1=26100200

Result 1=126

Similar questions