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 10, 2015 by BusIOSA
0 votes
16 views



Related Hot Questions

13 Answers

0 votes
NULL
answered Sep 10, 2015 by IgougeAlbers
0 votes
NULL
answered Sep 10, 2015 by DelLanger
0 votes
NULL
answered Sep 10, 2015 by suyesh.lokhande
0 votes
NULL
answered Sep 10, 2015 by SerenaBermud
0 votes
NULL
answered Sep 10, 2015 by sourabh
0 votes
NULL
answered Sep 10, 2015 by NannieLillic
0 votes
NULL
answered Sep 10, 2015 by PasqualeCyr
0 votes
NULL
answered Sep 10, 2015 by RamonJZFsdrw
0 votes
NULL
answered Sep 10, 2015 by KarMarrufo
0 votes
NULL
answered Sep 10, 2015 by SamTaverner
0 votes
NULL
answered Sep 10, 2015 by NilBurdine
0 votes
NULL
answered Sep 10, 2015 by DorieAckley
0 votes
NULL
answered Sep 10, 2015 by MiquelFraser

...