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 / manikandan [ gtec,vellore ]

Public is Visible to everywhere.
Private is visible to only the same class.
Protected is visible in same package and also sub classes in
any package.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Give some features of interface?

580


Why java is not 100% object-oriented?

824


What are the types of web technologies?

521


What is variable length arguments in java?

510


What is meant by object?

570






What is a jit compiler?

632


How do you join strings in java?

516


How are variables stored?

527


How is java hashmap implemented?

543


What is instanceof keyword?

717


What is a default constructor and also define copy contrucyor?

593


What are methods in java?

536


What are mutable classes?

521


What is the difference between superclass and subclass?

539


What is the diffrence between inner class and nested class?

558