Given:
import java.util.List; public class JobsDatabase { public static final String JOB_DB ="crm2023"; private long jobsCount; public Job findJob(int jobId){ int wage =0; int employerId; wage++; class Seeker{ Job seek( List<Job> jobs ){ System.out.println("________");//line 1 return jobs.get(jobId); } } return null; } } class Job { }import java.util.List; public class JobsDatabase { public static final String JOB_DB ="crm2023"; private long jobsCount; public Job findJob(int jobId){ int wage =0; int employerId; wage++; class Seeker{ Job seek( List<Job> jobs ){ System.out.println("________");//line 1 return jobs.get(jobId); } } return null; } } class Job { }
Which of the following variables can be used in line 1?
* JOB_DB
* jobsCount
* jobId
* wage
* employerId
* jobs
#java #certificationquestion #ocp
JOB_DB can be accessed from line 1.
Because a nested class that is not static can access all the static and non-static fields of the outer class.
jobsCount can be accessed from line 1.
Because a nested class that is not static can access all the static and non-static fields of the outer class.
jobId can be accessed from line 1.
Because after Java 8 both final nor effectively final local variables are accessible to the nested class.
Since jobId is effectively final, it is accessible.
wage CAN'T be accessed from line 1.
Because it is neither final nor effectively final. (Its value changed at "wage++;").
employerId CAN'T be accessed from line 1.
Because it is not initialized.
jobs can be accessed from line 1.