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

for the first line.. I would put : super(var1); second line: super.var3 = this.v

ID: 3575658 • Letter: F

Question

for the first line.. I would put :

super(var1);

second line: super.var3 = this.var3;

third line: Fubar = new Fubar(var2);

fourth line: I'm not so sure...

Can anyone help me on this...? am I doing these correctly?

public class Foo2 extends Fool private Fubar var2 private double var public Foo2 int varl, Fubar var2, double var3) Explicitly invoke super class Fool) constructor passing the parameter var1. Initialize the double instance variable to the parameter var Initialize the Fubar instance variable by invoking the copy ctor for Fubar with parameter var2 Assume a copy ctor for Fubar is defined public Foo2 Call same class ctor passing in 42 for varl, a new Fubar object invoking its no-arg ctor for 2, and 80.86 for var 3. var2 Assume a no-arg ctor for Fubar is defined.

Explanation / Answer


public class Foo2 extends Foo1{
  
   private Fubar var2;
   private double var3;
   public Foo2(int var1, Fubar var2, double var3){
       super(var1); //invoking super class Foo1 construtor
       this.var3 = var3; //we can use this for the current object instance variables
       this.var2 = new Fubar(var2);
  
   }
  
   public Foo2(){

       this(42, new Fubar(), 80.86); // pass the argument to the current class constructor where this refers to current object
      
   }
}