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 is ellipsis in java?
Does windows 10 need java?
What's the default access specifier for variables and methods of a class?
Which is better list or arraylist in java?
What is a JAR file?
What are aggregate functions explain with examples?
Is string an object?
How is treeset implemented in java?
What is an example of a boolean?
what is the difference between the methods sleep() and wait()? : Java thread
How many bits is a string in java?
Define an enumeration?
What is difference between length and length() method in java ?
How many bytes are there?
How do you declare an array that will hold more than 64KB of data?