Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

In the following Java code, what can directly access and change the value of the variable name?
package test;
class Target
{
public String name = “hello”;
}

In the following Java code, what can directly access and change the value of the variable name?
package test;
class Target
{
public String name = “hello”;
}
a) any class
b) only the Target class
c) any class in the test package
d) any class that extends Target

Answer: c
Explanation: Any class in the test package can access and change name.

Join The Discussion