Question: The value of myCount.count is displayed in the code below. What value is displayed? Choose the best answerpublic class Test { public static void main(String[]
The value of myCount.count is displayed in the code below. What value is displayed? Choose the best answerpublic 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; } }
A. 99
B. 98
C. 101
D. 100
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
