Question 13 options: //The first constructor in Apple is not complete. //Write t
ID: 3864913 • Letter: Q
Question
Question 13 options:
//The first constructor in Apple is not complete. //Write the code for that constructor.
public Apple(double pricePerPound, String code, String variety) {
}
Information
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) {
}
}
This code should be in java format.
Explanation / Answer
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){
super(pricePerPound,code);
this.variety=variety;
}
public Apple(String code){
super(code);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.