public class Fruit { private double pricePerPound; private String code; public F
ID: 3864935 • 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' but not specifying the other properties(java)
Explanation / Answer
public static void main(String a[]){
/*
This will invoke Apple(String code) constructor.
*/
Apple myApple=new Apple('pl102');
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.