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 escape a string?

508


What are aggregate functions explain with examples?

526


What is the structure of java?

508


How many ways can you break a singleton class in java?

490


Explain the concept of proper inheritance?

621






Why do we use variables?

515


What is the size of int?

600


What is abstraction in java?

619


Is simpledateformat safe to use in the multithreaded program?

541


Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

627


Is string a wrapper class?

518


What does substring mean?

515


What an i/o filter in java programming?

608


Explain the difference between jdk, jre, and jvm?

595


What is the difference between import java.util.date and java .util?

569