Multiple choice technology programming languages

Given: 1. package test; 2. 3. class Target { 4. public String name = "hello"; 5. } What can directly access and change the value of the variable name?

  1. any class

  2. only the Target class

  3. any class in the test package

  4. any class that extends Target

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The 'name' field has default (package-private) access: no public, private, or protected modifier. In Java, default access allows only classes within the same package to directly access the field. Option C correctly states 'any class in the test package' can access and modify name. Option A is wrong because classes outside the package cannot access it. Option B is wrong because other classes in the same package CAN access it (it's not private). Option D is wrong because extending the Target class alone doesn't grant access - you must be in the test package.