Question 1 : You are just doing the method call and not printing
System.out.println(p.toString());
This will print it
Question 2 : Override String toString()
method in the below Implementation class as well
programmieren.aufgabe4.PositionImplementation
@override
public String toString(){
return this.class.getName();
}
Otherwise, it would invoke the toString()
method belonging to any closer level super class. If it doesn't find any override of toString()
method in the inheritance tree, then the Object.toString()
method will be executed. Since all instances are of type Object