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 / r.jainrocks@gmail.com
a class which in same package
can access its variable name
no any class can access variable
1. class has default visibility so accessible in same package,
2. variable has public accessibility, can be access any class
which allowed in first condition.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain the advantages of packages in java?
What does n mean?
What is the importance of hashcode() and equals() methods?
What are recursive functions? Give some examples?
Is string is a keyword in java?
What is method in java ?
What is meant by main method?
What is the preferred size of a component in java programming?
What are reference variables in java?
What is the base class in java from which all classes are derived?
How do you check if a string is lexicographically in java?
What is final keyword in java?
What are constructors in java?
What an i/o filter?
Explain with example the concept of constant variable in java.