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
Explain restrictions on using enum?
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.
Why packages are used?
When should I use singleton pattern?
Are arrays primitive data types?
Which non-unicode letter characters may be used as the first character of an identifier?
What is the difference between inheritance and encapsulation?
What is %d in printf?
What is valid keyword in java?
What is a Null object?
How can we make a class singleton?
How does regex work?
How to perform binary search in java?
What is an inner class in java?
What are the 3 types of loops in java?