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

Does google use java?

540


Name and explain the types of ways which are used to pass arguments in any function in java.

571


What are the advantages of java over C++?

719


How do I find and replace in word?

533


What is a variable analysis?

642






How do I remove a character from a string in java?

504


How to calculate the length of a singly linked list in java?

584


Why do you canvas?

613


What are different access specifiers in java?

567


What is annotation in java?

578


Can we use a default constructor of a class even if an explicit constructor is defined?

655


Tell me a few examples of final classes defined in Java API?

564


What is a lock or purpose of locks in java?

595


What is multi-catch block in java?

618


Is void a data type in java?

526