Last active
April 26, 2017 13:45
-
-
Save ovidijusr/935e9bf85dcd9cab06ff722404595c8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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