Question: The variable times is displayed in the code below. What value is displayed? public class Test { public static void main(String[] args) { Count myCount
The variable times is displayed in the code below. What value is displayed?
public class Test { public static void main(String[] args) { Count myCount = new Count(); int times = 0; for (int i=0; i<100; i++) increment(myCount, times); System.out.println( "myCount.count = " + myCount.count); System.out.println("times = "+ times); } public static void increment(Count c, int times) { c.count++; times++; } } class Count { int count; Count(int c) { count = c; } Count() { count = 1; } } Possible solutions, select one:
| 98 |
| 101 |
| 100 |
| 0 |
| 99 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
