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 is set string?
Can a final variable be manipulated in java?
What is isa relationship?
Can we sort arraylist in java?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
What is ternary operator? Give an example.
What is the difference between Java1.4 and Java1.5
What is string intern in java?
What is an array length?
What is the default value of byte datatype in java?
What is the importance of hashcode() and equals() methods?
What is meant by string is immutable?
What are access specifiers in java ?
What does a void function return?
Why do we need data serialization?