Question: Find error(s), correct it and write output. |Points: 9 ( You are not allowed to add any new codes) package javaapplication11; public class Foo {



Find error(s), correct it and write output. |Points: 9

( You are not allowed to add any new codes)


package javaapplication11;


public class Foo {

private int times;

private Foo( )

{

times = 1;

}


}


package javaapplication11;


public class JavaApplication11 {


public static void main(String[] args) {

Foo mytimes = new Foo();

int time = 0;

for (int i = 0; i < 20; i++)

increment(mytimes, time);


System.out.println("times is " + mytimes.times);

System.out.println("times is " + time);

}


public static void increment(Foo f, int times)

{

f.times++;

times++;

}

}

//output:

Step by Step Solution

3.52 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here are the corrections to the code java package javaapplication11 public class Foo private int tim... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!