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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Mushfiq Mammadov
Posts: 32
Joined: Fri Oct 16, 2015 4:33 am
Contact:

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

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

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

herngyih
Posts: 6
Joined: Fri Jun 03, 2022 9:14 pm
Contact:

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

Post by herngyih »

What is "final" local variable good for?

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

herngyih
Posts: 6
Joined: Fri Jun 03, 2022 9:14 pm
Contact:

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

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

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

herngyih
Posts: 6
Joined: Fri Jun 03, 2022 9:14 pm
Contact:

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

Post by herngyih »

Thank you very much

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 35 guests