Skip to content

Instantly share code, notes, and snippets.

@0x8801
Last active September 24, 2015 13:01
Show Gist options
  • Save 0x8801/a2a7301f45da7f5089e6 to your computer and use it in GitHub Desktop.
Save 0x8801/a2a7301f45da7f5089e6 to your computer and use it in GitHub Desktop.
Inheritance & Polymorphism Simple Explanation
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