66,836 views
6 votes
6 votes
he superclass Student contains: a constructor that accepts a String corresponding to the name of the school the student attends a toString method that returns 'student at X' where X is the name of the school the student attends. Write a public subclass HighSchoolStudent, based on Student, which contains: a constructor accepting a String which is used as a parameter to the superclass constructor a toString method that returns 'high school student at X'. This method must use the toString method of its superclass.

User Aqeel Ahmad
by
2.9k points

1 Answer

17 votes
17 votes

Solution :

public
image Student {


image school
image

public
image(String school) {


image = school;

}

public String
image {

return
image + school;

}

}

HighSchool
image :

public class
image extends Student {

public
image(String school) {

super
image;

}

public String
image {

return
image + super.
image;

}

}

User Sandeep Bhandari
by
3.4k points