About Question enthuware.ocpjp.v7.2.1461 :

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

Moderator: admin

Post Reply
vijayanand
Posts: 10
Joined: Fri Sep 26, 2014 8:40 am
Contact:

About Question enthuware.ocpjp.v7.2.1461 :

Post by vijayanand »

This constructor has default access modifier which violates the fact that enum constructor should be private.

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

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

Post by admin »

No, even if you don't specify an enum's constructor as private, the compiler automatically makes it private.

everdelightedone
Posts: 3
Joined: Wed Apr 18, 2018 7:15 am
Contact:

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

Post by everdelightedone »

Hello, I just have cheked code fragment:

Code: Select all

public enum Coffee  {     
    ESPRESSO("Very Strong"), MOCHA, LATTE;  
    public String strength;   
    Coffee(String strength) {    
        this.strength = strength;    
    } 
}
And it compiles without issue on Java 8.
So, "2" isn't correct answer.

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

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

Post by admin »

Please make sure you type the code exactly as given in the question.

everdelightedone
Posts: 3
Joined: Wed Apr 18, 2018 7:15 am
Contact:

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

Post by everdelightedone »

I was wrong. My NetBeans didn't highlight an error for some reason.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests