8.4k views
5 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 DASPRiD
by
5.9k points

1 Answer

0 votes

Answer:

Following are the output of the given code:

Output:

12 20

Step-by-step explanation:

Description of the code:

  • In the java program code, two integer variable "j and k" is defined, that stores a value, that is "10 and 8", in its respective variable.
  • After storing the value it uses the "j and k" variable, in this, it increments the value of j with 2, and in the k variable, it adds the value of j and stores the value in k.
  • After incrementing the value, the print method is used that prints the value of "j and k", i.e, "12 and 20".
User Foolcage
by
6.1k points