Last active
September 24, 2015 13:01
-
-
Save 0x8801/a2a7301f45da7f5089e6 to your computer and use it in GitHub Desktop.
Inheritance & Polymorphism Simple Explanation
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
class parentClass { | |
public void parentMethod(){ | |
// do general stuff | |
} | |
} | |
class childClass extends parentClass { | |
public void childMethod1() { | |
// do child-specific stuff | |
} | |
public void childMethod2() { | |
// do child-specific stuff | |
} | |
public static void main(String[] args) { | |
parentClass parentObject = new parentClass(); | |
childClass childObject = new childClass(); | |
parentClass polymorphedObject = new childClass(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment