esempio:
class Animal classe principale
{
public void move()}
{System.out.println("Animals can move");}
public void move()}
{System.out.println("Dogs can walk and run");}
}
public static void main(String args[])
{Animal a = new Animal(); // Animal reference and object}
Animal b = new Dog(); // Animal reference but Dog object
a.move(); // runs the method in Animal class
b.move(); // runs the method in Dog class