About Question com.enthuware.ets.scjp.v6.2.456:
Moderator: admin
-
- Posts: 50
- Joined: Sun Nov 10, 2013 4:39 am
- Contact:
About Question com.enthuware.ets.scjp.v6.2.456:
What is exactly a top-level class. I've searched on the internet and from that top-level classes are classes which are not innerclasses.
But someone also stating that static class members (so static String string = new String()) are also top-level classes.
I didn't find definitions where I could judge that as right or wrong.
But someone also stating that static class members (so static String string = new String()) are also top-level classes.
I didn't find definitions where I could judge that as right or wrong.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.456 :
You may check this out: http://docs.oracle.com/javase/specs/jls ... jls-8.html
It explains all the terms.
HTH,
Paul.
It explains all the terms.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Fri Jun 20, 2014 3:36 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.456 :
Can you explain what a "package member class" means? I checked the link you provided and nothing is described in that manner.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.456 :
If you like our products and services, please help us by posting your review here.
-
- Posts: 57
- Joined: Sat Mar 01, 2014 1:48 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.456 :
The 2nd & 3rd sentences on that page state:admin wrote:You may check this out: http://docs.oracle.com/javase/specs/jls ... jls-8.html
In this code therefore, as its declaration occurs within the body of Test, Inner1 is a nested class, not a top level class.A top level class is a class that is not a nested class.
A nested class is any class whose declaration occurs within the body of another class or interface.
Code: Select all
class Test{
static class Inner1{
static class S1{ //ok
static class s2{} //ok
}
}
class Inner2{
// static class S3{} //compile error: static modifier not allowed here
}
}
This contradicts the explanation given for this question, which says:
As the positioning of S2 demonstrates, as long as only static classes are involved, it seems that nesting can continue to any depth.Only classes declared as members of top-level classes can be declared static.
Or, maybe I'm getting the terminology muddled up here?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.456 :
The problem is that Sun (when it had control over Java) has changed its terminology a couple of times on this. Earlier, when the explanation was written, static nested class was considered a top level class. Later on they changed the terminology.
Also, in section 8.1.3, it also says, "An inner class is a nested class that is not explicitly or implicitly declared static." Thus, Inner1 is not a nested class.
Since there hasn't been any new development on the Java 6 version of the exam, it is not clear which terminology one should go with. It is your call.
HTH,
Paul.
Also, in section 8.1.3, it also says, "An inner class is a nested class that is not explicitly or implicitly declared static." Thus, Inner1 is not a nested class.
Since there hasn't been any new development on the Java 6 version of the exam, it is not clear which terminology one should go with. It is your call.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 57
- Joined: Sat Mar 01, 2014 1:48 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.456 :
That explains it.
Thank you.
Thank you.
Who is online
Users browsing this forum: No registered users and 112 guests