Question: Describe the difference between passing a parameter of a primitive type and passing a parameter of a reference type. Show the output of the following

Describe the difference between passing a parameter of a primitive type and passing a parameter of a reference type. Show the output of the following programs:
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("count is "+ myCount.count); System.out.println("times is "+ times); } public static void increment(Count c, int times){ c.count++; times++; }} class Count { public int count; public Count(int c){ count = c; } public Count(){ count =1; }}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!