public class InheritanceExample { static public void main(String[] args){ Cat c = new Cat(); System.out.println(c.speak());
The Java(TM) way is to declare the protected String getSound() in Animal.java and implement it in the subclasses.