Page 1 of 1
					
				About Question enthuware.ocpjp.v7.2.1460 :
				Posted: Thu Mar 06, 2014 10:41 am
				by erbegu
				Can anyone explain why it is fine to put 
"public enum X{ X1,X2,X3}" in the first line and "enum Y{Y1,Y2,Y3}" in the second box and it is not fine to do the oposite?
Thank you.
			 
			
					
				Re: About Question enthuware.ocpjp.v7.2.1460 :
				Posted: Thu Mar 06, 2014 10:54 am
				by admin
				It is the reverse that you can't do because you can't have two public classes (or enums/interfaces) in the same file. (Except if they are inner classes/enums/interfaces.)
			 
			
					
				Re: About Question enthuware.ocpjp.v7.2.1460 :
				Posted: Thu Apr 03, 2014 5:49 am
				by Dadd80
				Good day.
Why does the answer is wrong? The code is compiling and running well.

 
			 
			
					
				Re: About Question enthuware.ocpjp.v7.2.1460 :
				Posted: Thu Apr 03, 2014 5:52 am
				by admin
				Unless mentioned otherwise, you need to fill all the yellow targets.
			 
			
					
				Re: About Question enthuware.ocpjp.v7.2.1460 :
				Posted: Thu Jan 14, 2016 8:40 am
				by MarcoGC
				At point 1 of the exaplanation for this question is said:
1) Enum constructor is always private. You cannot make it public or protected. If an enum type has no constructor declarations, then a private constructor that takes no parameters is automatically provided.
Is the first statement actually true?
I mean, I'm reading some cert books and I saw some code snippets where enum constructor had default access modifier.
Agree though they cannot have public or protected.
Thanks for the clarification.
Marco
 
			 
			
					
				Re: About Question enthuware.ocpjp.v7.2.1460 :
				Posted: Thu Jan 14, 2016 10:42 am
				by admin
				Yes, the given statement is correct.
default is not an access modifier. When there is no access modifier, that means it is default access.
For example,
class SomeClass{
 default int x; <- this is invalid because default is not a valid access modifier
 int y; <- this is valid and since there is no access modifer for y, it has default access.
}
In case of enums, when there is no access modifier for the constructor, it is considered private, that means default is private.
			 
			
					
				Re: About Question enthuware.ocpjp.v7.2.1460 :
				Posted: Thu Jan 14, 2016 10:58 am
				by MarcoGC
				Thank you very much. The point I was missing was exactly the last statement
 If no access modifier is specified for the constructor of an enum type, the constructor is private.
http://docs.oracle.com/javase/specs/jls ... #jls-8.8.3
This is a different behavior from "normal" classes constructors.
Point to remember.