About Question enthuware.ocpjp.v7.2.1463 :
Moderators: Site Manager, fjwalraven
-
- Posts: 17
- Joined: Tue Dec 18, 2012 7:54 pm
- Contact:
About Question enthuware.ocpjp.v7.2.1463 :
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.
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1463 :
Technically, semicolon is not necessary for definitions. For example, you don't need a semicolon when you define an inner class within a method:
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.
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);
}
}
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.
-
- Posts: 77
- Joined: Sun Jun 30, 2013 10:04 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1463 :
In the explanation, the number 4 appears twice.
It should only appear once as in
4.
5.
6.
Please confirm.
It should only appear once as in
4.
5.
6.
Please confirm.
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1463 :
You are right. It should be 5. Fixed.
thank you for your feedback.
-Paul.
thank you for your feedback.
-Paul.
Who is online
Users browsing this forum: Bing [Bot] and 4 guests