Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) LIST THE OUTPUT POR THE PROGRAM BELOw class A public int vi-1 public static i

ID: 3594610 • Letter: 1

Question

1) LIST THE OUTPUT POR THE PROGRAM BELOw class A public int vi-1 public static int v2 2 public int v3 -3 public int fl(int v) int v3 v2V3 +2 viv2+ v3; return (v2) public int f2(int vl, int v) v2 f1(vl); V v2 + vl; return (v+2); public static void main (String argv [1) A ol, o2, 03 01 = new A(); o2 new A(); o3-02 ; 01 .v3 = o2 . f1 (2 ) ; System.out.println(ol.v1 o1.v2ol.v3) System.out.printin (o2.vl+ ""+ 02.v202.v3): System.out.println (o3.vi03.v2 03.v3) 03.v2 = 2.f2 (01 . v1 , 02.v2); System system.out.println (02.v102.Y22.v3) System.out.println (03.v103.y203.v3) .out.println(ol.vl ol.v21.v3)

Explanation / Answer

Program:

/* package codechef; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Codechef

{

public int v1=1;

public static int v2=2;

public int v3=3;

public int f1(int v)

{

int v3;

v3=v+1;

v2=v3+2;

v1=v2+v3;

return (v1);

}

public int f2(int v1,int v)

{

v3=v+1;

v2=f1(v1);

v=v2+v1;

return (v+2);

  

}

  

public static void main (String[] args) throws java.lang.Exception

{

// your code goes here

Codechef o1,o2,o3;

o1 =new Codechef();

o2 =new Codechef();

o3 =o2;

o1.v3=o2.f1(2);

System.out.println(o1.v1+" "+o1.v2+" "+o1.v3);

System.out.println(o2.v1+" "+o2.v2+" "+o2.v3);

System.out.println(o3.v1+" "+o3.v2+" "+o3.v3);

o3.v2=o2.f2(o1.v1,o2.v2);

System.out.println(o1.v1+" "+o1.v2+" "+o1.v3);

System.out.println(o2.v1+" "+o2.v2+" "+o2.v3);

System.out.println(o3.v1+" "+o3.v2+" "+o3.v3);

}

}

Output:

1 5 8
8 5 3
8 5 3
1 9 8
6 9 6
6 9 6