Question: Can anyone explain me the result of this execution? I can't notice why each method is called. And how we distinguish the real type vs the apparent type. Thank you :) 

```
public class JavaApplication15 {
   public static void main(String[] args) {
       A a = new A();
       B b= new B();
       A ab = new B();
       b.f(a);
       b.f(b);
       b.f(ab);
  }  
}

public class A {
   private final String id="A";
   public void f(A x){
     System.out.println("Send a fax to "+ x ) ;
  }
  public String toString(){return id;}
}

public class B extends A{
   private final String id="B";
   public void f(B x){
     System.out.println("Send an email to"+ x ) ;
   }
   public String toString(){return id;}
}

```

Result:

```
Send a fax to A
Send an email to B
Send a fax to B

```

Answer: 
```
@Override
public String toString()
{
    return id;
}

```

This defines how the class is outputted. When you call a function such as the following:

```
b.f(a)

```

You are inputting a class as the parameter. Because of your `toString()` method, which is an override of the standard method to output your class, you display the `id` after `Send an email to`.
Since `B` extends `A` and A has a public method. So it has both of the following methods - 

```
public void f(A x){
     System.out.println("Send a fax to "+ x ) ;
} 

```

And - 

```
public void f(B x){
     System.out.println("Send an email to"+ x ) ;
}

```

Actually the seond method in `B` is an overloaded version of method `void f(A x)` inherited from `A`