Home / Questions / What will be the output of the following code? (i) int k = 5, j = 9; k += k - j + k; System.out.println("k = " + k); System.out.println("j = " + j); (ii) double b = -15 * 6; double a = Math.rint(Math.abs(b)); System.out.println("a = " + a);
Explanatory Question

What will be the output of the following code?

(i)


int k = 5, j = 9;

k += k - j + k;

System.out.println("k = " + k);
System.out.println("j = " + j);

(ii)



double b = -15 * 6;
double a = Math.rint(Math.abs(b));

System.out.println("a = " + a);

👁 110 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Output of the code:

(i)


int k = 5, j = 9;
k += k - j + k;   // k = 5 + 5 - 9 + 5 = 6
System.out.println("k = " + k);
System.out.println("j = " + j);

Output:

k = 6
j = 9

Output of the code:

(ii)


double b = -15 * 6;   // b = -90
double a = Math.rint(Math.abs(b));   // Math.abs(b) = 90, Math.rint(90) = 90
System.out.println("a = " + a);

Output:

a = 90.0