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


Please Help Members By Posting Answers For Below Questions

How do you use nextline in java?

697


What is the use of conditional statement?

740


What is hash in java?

708


Is an empty arraylist null?

801


Is there any case when finally will not be executed?

721


Difference between start() and run() method of thread class?

814


Is break statement can be used as labels in java?

709


Which is bigger float or double java?

744


Can you change array size in java?

739


What is constructor chaining and how is it achieved in java?

782


What is jvm? Why is java called the platform independent programming language?

766


What does java ide mean?

836


Can private members of a base class are inheritable justify?

683


How can an object be unreferenced?

753


Difference between character constant and string constant in java ?

779