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
What are new features introduced with java 8 ?
How to perform bubble sort in java?
What is the program development process?
Difference between final and effectively final ? Why is effectively final even required ?
State the difference between creating string as new () and literal.
When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?
How to declare an arraylist in java?
What is functional interface in javatpoint?
Is ++ operator is thread safe in java?
What is the public field modifier?
What is an infinite loop in java? Explain with an example.
How can you traverse a linked list in java?
What is the difference between yielding and sleeping in java programming?
What is scope & storage allocation of global and extern variables? Explain with an example
What are methods of a class?