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);
Views 9
Answer:
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
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.