What is the use of anonymous inner classes ?
Answer Posted / suneetha
The use of anonymous inner classes is to access the data of
outer class.Even private data also we can access.
button.addActionListerner(new ActionListener(){
public void actionPerformed(){}
});
here we are using anonymous class to implement
ActionListener interface.If at all we are using other class
that implements ActionListener interface and passing that
obj into
button.addActionListener(obj);
In this method we cant access the private variables of the
class that call button.addActionListener();
| Is This Answer Correct ? | 7 Yes | 4 No |
Post New Answer View All Answers
What is incompatible types in java?
How can you say java is object oriented?
Can we make a constructor final?
What are 4 pillers of object orinted programming?
How do you check if a number is a perfect square?
Justify your answer that you can't define a method inside another method in java, if you can then how?
What is the technique adopted to create an immutable class?
What is meant by design patterns?
Can we have two methods in a class with the same name?
What is difference between string and new string?
Why do we use regex?
What do you know about the garbate collector?
Where is the singleton class used?
What is the difference between == and === javascript?
What is the latest java version?