Given:
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.