About Question enthuware.ocpjp.v7.2.1480 :
Moderators: Site Manager, fjwalraven
-
- Posts: 5
- Joined: Wed Apr 17, 2013 2:41 pm
- Contact:
About Question enthuware.ocpjp.v7.2.1480 :
Is it right to say that class Inner cannot be accessed outside of the inner() method? I tried it out I can't seem to access it from main.
Thanks.
Thanks.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
Yes, that is correct.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
Why I am seeing only answer number 1 as the correct?
Which is the other one?
Thanks in advance.
The_Nick.
Which is the other one?
Thanks in advance.
The_Nick.
-
- Posts: 30
- Joined: Fri Dec 07, 2012 6:09 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
All Static VariablesThe_Nick wrote:Why I am seeing only answer number 1 as the correct?
Which is the other one?
Thanks in advance.
The_Nick.
All Final Automatic Variables.
-
- Posts: 30
- Joined: Fri Dec 07, 2012 6:09 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
There is a problem with the explanation code -- I don't think it changes the point being made but still, it should compile:
Code: Select all
public static void main( String[] args ) { TestClass.inner(); }
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
The code given in the explanation compiles fine. I just tried it.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
Hi,
all final automatic variables OK but only the ones within the static enclosing method. (not exactly all) just pointing out.
The_Nick.
all final automatic variables OK but only the ones within the static enclosing method. (not exactly all) just pointing out.
The_Nick.
-
- Posts: 53
- Joined: Fri Sep 20, 2013 7:20 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
Hi,
"Which variables of the encapsulating class"
and in the answer "only si and fai are accessible in class Inner."
Both the answer and explanation given are inconsistent with the wording used in the question. A local (automatic) variable is NOT a variable of the encapsulating class.
Variable fai is NOT a variable of the encapsulating class TestClass. It's a variable of the method inside which Inner is defined.
There are class level (static and non-static) variables, and there are local variables. So the wording of the question and/or answer needs to be revised.
"Which variables of the encapsulating class"
and in the answer "only si and fai are accessible in class Inner."
Both the answer and explanation given are inconsistent with the wording used in the question. A local (automatic) variable is NOT a variable of the encapsulating class.
Variable fai is NOT a variable of the encapsulating class TestClass. It's a variable of the method inside which Inner is defined.
There are class level (static and non-static) variables, and there are local variables. So the wording of the question and/or answer needs to be revised.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
The problem statement has now been updated to "Which variables declared in the encapsulating class or in the method..."
Hope that makes it clearer. Thank you for your feedback!
-Paul.
Hope that makes it clearer. Thank you for your feedback!
-Paul.
-
- Posts: 53
- Joined: Fri Sep 20, 2013 7:20 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1480 :
Okey dokey, cheers.
Who is online
Users browsing this forum: No registered users and 9 guests