About Question enthuware.ocpjp.v7.2.1461 :
Moderator: admin
-
- Posts: 10
- Joined: Fri Sep 26, 2014 8:40 am
- Contact:
About Question enthuware.ocpjp.v7.2.1461 :
This constructor has default access modifier which violates the fact that enum constructor should be private.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1461 :
No, even if you don't specify an enum's constructor as private, the compiler automatically makes it private.
-
- Posts: 3
- Joined: Wed Apr 18, 2018 7:15 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1461 :
Hello, I just have cheked code fragment:
And it compiles without issue on Java 8.
So, "2" isn't correct answer.
Code: Select all
public enum Coffee {
ESPRESSO("Very Strong"), MOCHA, LATTE;
public String strength;
Coffee(String strength) {
this.strength = strength;
}
}
So, "2" isn't correct answer.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1461 :
Please make sure you type the code exactly as given in the question.
-
- Posts: 3
- Joined: Wed Apr 18, 2018 7:15 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1461 :
I was wrong. My NetBeans didn't highlight an error for some reason.
Who is online
Users browsing this forum: Bing [Bot] and 4 guests