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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
bluster
Posts: 60
Joined: Wed Apr 23, 2014 6:38 pm
Contact:

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

Post 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());
    }
}
Last edited by admin on Thu Aug 21, 2014 8:39 pm, edited 1 time in total.
Reason: Updated subject to scramble qid

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

And that is the correct answer :)
So what is the issue?

bluster
Posts: 60
Joined: Wed Apr 23, 2014 6:38 pm
Contact:

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

Post by bluster »

Sorry, must be losing it with all the study.. :(

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests