What value should replace KK in line x to cause jj = 5 to be output?

Give:
public class MyFive {
static void main(String[] args) {
short ii;
short jj = 0;
for (ii = kk;ii > 6; ii -= 1) { // line x //
jj++;
}
System.out.println(“jj = ” + jj);
}

}
What value should replace KK in line x to cause jj = 5 to be output?

Give:
public class MyFive {
static void main(String[] args) {
short ii;
short jj = 0;
for (ii = kk;ii > 6; ii -= 1) { // line x //
jj++;
}
System.out.println(“jj = ” + jj);
}

}
What value should replace KK in line x to cause jj = 5 to be output?

A.
-1

B.
1

C.
5

D.
8

E.
11

Explanation:
We need to get jj to 5. It is initially set to 0. So we need to go through the for loop 5
times. The for loops ends when ii > 6 and ii decreases for every loop. So we need to initially set ii
to 11. We set kk to 11.



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Amadeuszx

Amadeuszx

There is no KK in line x 🙁

Hans

Hans

for (ii = kk;ii > 6; ii -= 1) { // line x //

E.