127k views
2 votes
Consider the following code segment. int j = 10; int k = 8; j += 2; k += j; System.out.print(j); System.out.print(" "); System.out.println(k); What is printed when the code segment.

User Kingkong
by
8.3k points

1 Answer

3 votes

Answer:

12 20

Step-by-step explanation:

alright so, lets keep track of our variables

j+= 2 is j = j+2

so j is 12, and k += j is k = k + j so k is then 20.

j=12, k=20

It would print

12 20

because of the "space" on your second print statement, and the third would create a new line AFTER printing itself first.

User BurtonLowel
by
8.0k points