About Question enthuware.ocpjp.v7.2.1463 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
jklb
Posts: 17
Joined: Tue Dec 18, 2012 7:54 pm
Contact:

About Question enthuware.ocpjp.v7.2.1463 :

Post 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.

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

ewebxml
Posts: 77
Joined: Sun Jun 30, 2013 10:04 pm
Contact:

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

Post by ewebxml »

In the explanation, the number 4 appears twice.
It should only appear once as in
4.
5.
6.


Please confirm.

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

You are right. It should be 5. Fixed.
thank you for your feedback.
-Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests