Created
June 12, 2015 09:55
Revisions
-
dapurv5 created this gist
Jun 12, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ class Base { static int x = 0; int m = 0; } class Derived extends Base { static int x = 2; int m = 3; public static void fun() { System.out.println(x); // Compiler Error: non-static variable // cannot be referenced from a static context } public void fun2() { System.out.println(m); } } /** * @author dapurv5 */ public class InheritanceDemo { public static void main(String[] args) { Derived d = new Derived(); Derived.fun(); d.fun2(); } }