If we have for example :
class Person {
  // public void printInfos(){ }
}
class Student extends Person {
     public void printInfos(){
          System.out.println("studentInfos");
     }
}
class Teacher extends Person(){
     public void printInfos(){
          System.out.println("teacherInfos");
     }
}
main:
Person p1 = new Student();
Person p2 = new Teacher();
I want to write : p1.printInfos() and p2.printInfos() and print "studentInfos" & "teacherInfos" but I can't find a solution other than declaring an empty method inside the class Person (since we can't declare it as abstract and override it otherwise there will be no instanciation possible). I feel that the declaration of an empty method is wrong even if it works.
 
     
     
    