Created
June 1, 2016 07:59
-
-
Save asicfr/bd1cf175cbdfa465d953d31382683c41 to your computer and use it in GitHub Desktop.
The distinction between hiding and overriding method
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 A { | |
public static void display() { | |
System.out.println("Inside static method of superclass"); | |
} | |
} | |
class B extends A { | |
public void show() { | |
display(); | |
} | |
public static void display() { | |
System.out.println("Inside static method of this class"); | |
} | |
} | |
public class Test { | |
public static void main(String[] args) { | |
B b = new B(); | |
b.display(); | |
A a = new B(); | |
a.display(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment