Created
October 7, 2015 12:53
-
-
Save smamran/23c0342a869d12cdd7e7 to your computer and use it in GitHub Desktop.
Abstract Class Method Implementation
This file contains hidden or 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
| package slidenerd.javaoop; | |
| /** | |
| * Created by Microsoft on 10/7/2015. | |
| */ | |
| public class AbstractMethodImplementation { | |
| public static void main(String[] args) { | |
| AbstractText abstractText = new AbstractText(); | |
| abstractText.printSubInfo(); // SubClass info | |
| abstractText.printSuperInfo(); // SubClass info | |
| } | |
| } | |
| abstract class SuperClass { | |
| String info = "SuperClass info"; | |
| abstract void printSuperInfo(); | |
| } | |
| abstract class SubClass extends SuperClass { | |
| String info = "SubClass info"; | |
| abstract void printSubInfo(); | |
| } | |
| class AbstractText extends SubClass { | |
| @Override | |
| void printSubInfo() { | |
| System.out.println(super.info); // SubClass info | |
| } | |
| @Override | |
| void printSuperInfo() { | |
| System.out.println(super.info); // SubClass info | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment