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 meant by polymorphism?
Is string a datatype?
Does java isempty check for null?
What is the difference between heap memory and stack memory?
Explain why wait(), notify() and notifyall() methods are in object class rather than in the reading class?
Convert a BST into a DLL and DLL to BST in place.
What is the purpose of checked and unchecked exceptions in JAVA?
What does the string method compareto () do?
What does substring mean?
What is internal iteration in java se 8?
What is a lock or purpose of locks in java?
Define linked list and its features with signature?
What are the advantages of packages in java?
What are different types of encoding?
What are the four pillars of java?