Page 1 of 1

About Question enthuware.ocpjp.v7.2.1463 :

Posted: Fri Apr 19, 2013 9:47 pm
by jklb
Lines 5, 6 and 8 are missing semi-colons which would make them incorrect irrelevant of the fact that enums cannot be defined inside any methods or constructors (which I hadn't known about!). Also, the declaration of main() in line 7 is missing "String args[]", so I marked that statement as being wrong although it's marked as being correct.

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

Posted: Sat Apr 20, 2013 6:58 am
by admin
Technically, semicolon is not necessary for definitions. For example, you don't need a semicolon when you define an inner class within a method:

Code: Select all

public class TestClass{
   public static void main(String[] args){
     class X{ 
     }       //no semi colon here
     X xx = new X();
     System.out.println(xx);
   }	
}
So it should not be required for definition of an enum either. So the only reason they are invalid is because enums cannot be defined within a method.

Just because the name of the method is main, doesn't mean it has to have String[] args. It is still a valid method without String[] args.

HTH,
Paul.

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

Posted: Wed May 21, 2014 4:22 pm
by ewebxml
In the explanation, the number 4 appears twice.
It should only appear once as in
4.
5.
6.


Please confirm.

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

Posted: Wed May 21, 2014 8:45 pm
by admin
You are right. It should be 5. Fixed.
thank you for your feedback.
-Paul.