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
How do you use nextline in java?
What is the use of conditional statement?
What is hash in java?
Is an empty arraylist null?
Is there any case when finally will not be executed?
Difference between start() and run() method of thread class?
Is break statement can be used as labels in java?
Which is bigger float or double java?
Can you change array size in java?
What is constructor chaining and how is it achieved in java?
What is jvm? Why is java called the platform independent programming language?
What does java ide mean?
Can private members of a base class are inheritable justify?
How can an object be unreferenced?
Difference between character constant and string constant in java ?