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.
Related Posts
Operating System maintains the page table for ____________
What is compaction?
The page table contains ____________
Program always deals with ____________
The address of a page table in memory is pointed by ____________
Memory management technique in which system stores and retrieves data from secondary storage for use in main memory is called?
Run time mapping from virtual to physical address is done by ____________
Join The Discussion