Polimorfismo de Java Cómo llamar al método de superclase para objeto de subclase
Aquí hay un ejemplo de lo que estoy tratando de preguntar.
Superclase Name.java
public class Name{
protected String first;
protected String last;
public Name(String firstName, String lastName){
this.first = firstName;
this.last = lastName;
}
public String initials(){
String theInitials =
first.substring(0, 1) + ". " +
last.substring(0, 1) + ".";
return theInitials;
}
y luego la subclase es ThreeNames.java
public class ThreeNames extends Name{
private String middle;
public ThreeNames(String aFirst, String aMiddle, String aLast){
super(aFirst, aLast);
this.middle = aMiddle;
}
public String initials(){
String theInitials =
super.first.substring(0, 1) + ". " +
middle.substring(0, 1) + ". " +
super.last.substring(0, 1) + ".";
return theInitials;
}
así que si creo un objeto Threename conThreeNames example1 = new ThreeNames("Bobby", "Sue" "Smith")
y luego llamarSystem.out.println(example1.initials());
ObtendréB.S.S.
Lo entiendo.
Mi pregunta es si hay una manera de llamar al método de iniciales que está en la clase Nombre para que mi salida sea simplementeB.S.