Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1004 :

Posted: Mon Oct 19, 2015 1:19 pm
by Mushfiq Mammadov
Image

1) The first underlined statement:
We can also declare local variables in instance initializer and static initializer blocks, or in Constructors too. It may be written as this:
"A local variable (aka automatic variable) means a variable declared in a method or block of code".


2) The second underlined statement:
It is a bit confused. If we apply static to instance variable so it will not be instance variable, however it will be class variable.

Re: About Question enthuware.ocajp.i.v8.2.1004 :

Posted: Mon Oct 19, 2015 9:40 pm
by admin
1. Fixed.
2. Yes, if you apply static to an instance field, it won't remain instance field after that. But the fact still remains that you can apply static to an instance variable.

HTH,
Paul.

Re: About Question enthuware.ocajp.i.v8.2.1004 :

Posted: Fri Jun 03, 2022 9:22 pm
by herngyih
What is "final" local variable good for?

Re: About Question enthuware.ocajp.i.v8.2.1004 :

Posted: Fri Jun 03, 2022 10:17 pm
by admin
It is a good to convey the intention of the programmer that the value of that variable is not going to change. Compiler can also apply better optimization techniques if a variable is final. So basically, applying final to a local variable gives the same benefits as applying final to any other variable.

Re: About Question enthuware.ocajp.i.v8.2.1004 :

Posted: Fri Jun 03, 2022 10:42 pm
by herngyih
Thank you for your reply. May I ask as for this kind of question,is the purpose of it is to test the logical thinking of candidate? I don't see the study guide putting emphasize on it. What matter is the scoping of the variable. I might have missed something.

Re: About Question enthuware.ocajp.i.v8.2.1004 :

Posted: Fri Jun 03, 2022 11:11 pm
by admin
Unfortunately, it is true to a great extent that the exam tests more on the language features, APIs, and syntax than good development practices. Since our goal is to help the candidates pass the exam, we try to keep our questions close to what one can expect in the real exam.

But it is alright, there are pros and cons for every thing. So, I would suggest you to not worry about the style of the exam and just focus on learning what is required. Based on our experience, we think you will definitely be benefited in the long run by studying for the exam.

Re: About Question enthuware.ocajp.i.v8.2.1004 :

Posted: Fri Jun 03, 2022 11:47 pm
by herngyih
Thank you very much