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

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

Moderator: admin

Post Reply
jamesmccreary
Posts: 22
Joined: Sun Jan 15, 2017 10:51 pm
Contact:

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

Post by jamesmccreary »

From reading the Oracle docs regarding primitive default initialization, local variables (method variables) are not given a default value. Is that why:

for(int k; k<0; k++)

is incorrect? Is a for loop considered a method?

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

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

Post by admin »

No, for loop is not considered a method. But the variable defined in a for loop is a local variable with scope limited to just the for loop body. So it is not given a default value.

jamesmccreary
Posts: 22
Joined: Sun Jan 15, 2017 10:51 pm
Contact:

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

Post by jamesmccreary »

Thank you for the clarification!

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests