Consider the classes below: public class TestA { public static void main(String[] args) { ​ int x = 2; ​ int y = 20 ​ int counter = 0; ​ for (int j = y % x; j < 100; j += (y / x)) { ​ counter++; ​ } } } public class TestB { public static void main(String[] args) { ​ int counter = 0; ​ for (int j = 10; j > 0; --j) { ​ ++counter; ​ } } } Which of the following statements is true?a. The value of j will be the same for each loop for all iterations b. The value of counter will be different at the end of each for loop for each class. c. Both A and B are true. d. Neither A nor B is true.

Respuesta :

Answer:

The answer is "Option d".

Explanation:

In the given code, two class "TestA and TestB" is defined, that calculates some values which can be described as follows:

  • In class "TestA", three integer variable "x, y, and counter" is declared, that initializes with a value, that is "2, 20, and 0", inside the class for loop is declare that uses variable j which starts from and ends when the value of j is less than 100, it will increment the value of counter variable by 1.
  • In the class "TestB", an integer "counter" variable is initializes a value with 0, inside the class the for loop is used that uses variable j, which starts from 10, and ends when j is less than 0. in the loop it increments the value of "counter" variable by 1.  that's why in this question except "option d" all were wrong.