Organizational Research By

Surprising Reserch Topic

Experts Most Trusted 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



Walkin Jobs Opening



Government Jobs Opening


...