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
Can we force garbage collector to run ?
What is the difference between state-based unit testing and interaction-based unit testing?
Java.util.regex consists of which classes?
How do you allocate memory to object?
What about main() method in java ?
How can we break singleton in java?
What are thread groups?
Is null a value?
What happens when main () method is declared as private?
Which is better stringbuilder or stringbuffer?
What is the difference between static class and normal class?
Explain abstract class in java?
Can we pass null as argument in java?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
Which graphs are functions?