Skip to content

Instantly share code, notes, and snippets.

@ovidijusr
Last active April 26, 2017 13:45
Show Gist options
  • Save ovidijusr/935e9bf85dcd9cab06ff722404595c8a to your computer and use it in GitHub Desktop.
Save ovidijusr/935e9bf85dcd9cab06ff722404595c8a to your computer and use it in GitHub Desktop.
public class Animal {
public static void hide() {
System.out.println("The hide method in Animal.");
}
public void override() {
System.out.println("The override method in Animal.");
}
}
public class Cat extends Animal {
public static void hide() {
System.out.println("The hide method in Cat.");
}
public void override() {
System.out.println("The override method in Cat.");
}
public static void main(String[] args) {
Cat myCat = new Cat();
Animal myAnimal = (Animal)myCat;
myAnimal.hide();
myAnimal.override();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment