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

public class Fruit { private double pricePerPound; private String code; public F

ID: 3864933 • Letter: P

Question

public class Fruit {

    private double pricePerPound;

    private String code;

    public Fruit(double pricePerPound, String code) {

        this.pricePerPound = pricePerPound;

        this.code = code;

    }

    public Fruit(String code) {

        this.code = code;

    }

}

public class Apple extends Fruit {   

private String variety;    

public Apple(double pricePerPound, String code, String variety) {   

}    

public Apple(String code) {   

}  

}

Write the code that will assign the variable 'myApple' a new Apple with code 'pl102', variety 'Pink Lady' and price per pound 1.49(JAVA)

Explanation / Answer

public static void main(String args[]) {

double pricePerPound = 1.49;
String code = "pl102";
String variety = "Pink Lady";
Apple myApple = new Apple(pricePerPound, code, variety);

// Fruit myApple = new Apple(pricePerPound, code, variety);

}