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
Answer Posted / amit singh
first i want to see the visibility of class itis
default acees
the class is default acess so this class is visible in a
same package
so then the member in it public so
1)so the class in the same package will acess it
2)the class in the same package which extends this class
can acess it
not any other class in the whole world or subclass in other
package.
thanks amit singh
amitsing2008@gmail.com
| Is This Answer Correct ? | 17 Yes | 0 No |
Post New Answer View All Answers
What are the files generated after using IDL to java compiler?
What are the two environment variables that must be set in order to run any java programs?
Which list does not allow duplicates in java?
Explain working of call by reference function invoking.
Write an algorithm program in java for the following question.. 1) S is a set of integers.X is an integer obtained by sum of two digits in S. Write logic for whether or not the X is from the S. The time of algorithm should not exceed o(n logn).
Why is core java important?
What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?
Why is multithreading important?
What is the purpose of static methods and variables?
Find the value of a specified element of the array arr[i] where 0 <= i <= n-1
How to compare strings in java?
Is jdk required on each machine to run a java program?
Explain differences between checked and unchecked exceptions in java?
What is difference between iterator and enumeration in java?
Which sorting algorithm is in place?