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

Explain restrictions on using enum?

853


Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.

2506


Why packages are used?

933


When should I use singleton pattern?

823


Are arrays primitive data types?

873


Which non-unicode letter characters may be used as the first character of an identifier?

825


What is the difference between inheritance and encapsulation?

882


What is %d in printf?

779


What is valid keyword in java?

780


What is a Null object?

1245


How can we make a class singleton?

843


How does regex work?

762


How to perform binary search in java?

807


What is an inner class in java?

749


What are the 3 types of loops in java?

756