Page 1 of 1
About Question enthuware.ocpjp.v7.2.1461 :
Posted: Fri Oct 31, 2014 7:04 am
by vijayanand
This constructor has default access modifier which violates the fact that enum constructor should be private.
Re: About Question enthuware.ocpjp.v7.2.1461 :
Posted: Fri Oct 31, 2014 7:10 am
by admin
No, even if you don't specify an enum's constructor as private, the compiler automatically makes it private.
Re: About Question enthuware.ocpjp.v7.2.1461 :
Posted: Wed Apr 18, 2018 7:18 am
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.
Re: About Question enthuware.ocpjp.v7.2.1461 :
Posted: Wed Apr 18, 2018 7:22 am
by admin
Please make sure you type the code exactly as given in the question.
Re: About Question enthuware.ocpjp.v7.2.1461 :
Posted: Wed Apr 18, 2018 9:42 am
by everdelightedone
I was wrong. My NetBeans didn't highlight an error for some reason.