Answer:
Step-by-step explanation:
The following derived class called StringInstrument extends the Instrument class and creates the necessary private variables for number of Strings and number of Frets. Then it creates getter and setter methods for each of the variables. This allows them to be called within the main method that has already been created and output the exact sample output as seen in the question.
class StringInstrument extends Instrument {
private int numStrings, numFrets;
public int getNumOfStrings() {
return numStrings;
}
public void setNumOfStrings(int numStrings) {
this.numStrings = numStrings;
}
public int getNumOfFrets() {
return numFrets;
}
public void setNumOfFrets(int numFrets) {
this.numFrets = numFrets;
}
}