2 min read•december 21, 2021
Milo Chang
Milo Chang
public class Student
{
private String name;
public Student (String newName)
{
name = newName;
}
public void setName (String newName)
{
name = newName;
}
public String getName ()
{
return name;
}
}
public class Athlete extends Student
{
public void printName ()
{
System.out.println(name); // THIS WILL NOT WORK
}
// There may be instance variables, constructors, and other methods not
// shown.
}
© 2023 Fiveable Inc. All rights reserved.