Organizational Research By

Surprising Reserch Topic

is there a way to override class variables in java


is there a way to override class variables in java  using -'java,inheritance,override'

class Dad
{
    protected static String me = "dad";

    public void printMe()
    {
        System.out.println(me);
    }
}

class Son extends Dad
{
    protected static String me = "son";
}

public void doIt()
{
    new Son().printMe();
}


The function doIt will print "dad". Is there a way to make it print "son"?
    

asked Sep 9, 2015 by KarolinO07rt
0 votes
7 views



Related Hot Questions

13 Answers

0 votes
NULL
answered Sep 9, 2015 by CamilleCoffe
0 votes
NULL
answered Sep 9, 2015 by ChasKlugzcil
0 votes
NULL
answered Sep 9, 2015 by LinKeartlan
0 votes
NULL
answered Sep 9, 2015 by AdeYcr
0 votes
NULL
answered Sep 9, 2015 by SharylTruger
0 votes
NULL
answered Sep 9, 2015 by JodWorkman
0 votes
NULL
answered Sep 9, 2015 by MadeleinDunk
0 votes
NULL
answered Sep 9, 2015 by TanSimpkins
0 votes
NULL
answered Sep 9, 2015 by JeanneMalerq
0 votes
NULL
answered Sep 9, 2015 by NelleHelveyw
0 votes
NULL
answered Sep 9, 2015 by FranziskaPet
0 votes
NULL
answered Sep 9, 2015 by BobVCUoseaqm
0 votes
NULL
answered Sep 9, 2015 by EthanS17cgzy

...