Page 1 of 1

About Question enthuware.ocpjp.v7. 2. 1726 :

Posted: Thu Aug 21, 2014 10:50 am
by bluster
This compiled OK and produced "thegoodpart", in javac 1.7.0_51. Please advise.

Code: Select all

public class Onion {
    private String data = "skin";
    
    private class Layer extends Onion {
        String data = "thegoodpart";
        public String getData() {
            return data;
        }
    }

    public String getData() {
        return new Layer().getData();
    }

    public static void main(String[] args) {
        Onion o = new Onion();
        System.out.println(o.getData());
    }
}

Re: About Question enthuware.ocpjp.v7.2.1726 :

Posted: Thu Aug 21, 2014 11:15 am
by admin
And that is the correct answer :)
So what is the issue?

Re: About Question enthuware.ocpjp.v7.2.1726 :

Posted: Thu Aug 21, 2014 11:44 am
by bluster
Sorry, must be losing it with all the study.. :(