Consider the classes below:
public class TestA
{
public static void main( String args[] )
{
int x = 2, y = 20, counter = 0;
for ( int j = y % x; j < 100; j += ( y / x ) )
counter++;
} // end main
} // end class TestA
public class TestB
{
public static void main(String args[])
{
int counter = 0;
for ( int j = 10; j > 0; --j )
++counter;
} // end main
} // end class TestB
Which of the following statements is true?

Respuesta :

Answer:

The correct answer is D.

Neither (a) nor (b) is true.

Explanation:

The question image is attached.

Option A is not correct because the both program have the same value for counter after execution.

Option B is also not correct because the value of j changes during the for loop execution. If it doesn't change; there will be an infinite loop. Though the initial values assigned to j is the same (10) for each of the loop.

Option C is not correct as it select both A and B

Option D is the correct option as it is neither A nor B

Ver imagen ibnahmadbello