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: 10036
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.
If you like our products and services, please help us by posting your review here.

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: 10036
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.
If you like our products and services, please help us by posting your review here.

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: Google [Bot] and 38 guests