What is the use of anonymous inner classes ?
Answer Posted / reddy vatti
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 ? | 0 Yes | 0 No |
Post New Answer View All Answers
Is char a method in java?
What are the 6 mandatory procedures for iso 9001?
What is return null in java?
How would you format a date in java? I.e. In the ddmmyyy format?
What happens when you add a double value to a string?
Difference between method overloading and method overriding in java ?
Is it possible for yielded thread to get chance for its execution again ?
When should the method invokelater() be used?
Can we declare a static variable inside a method?
What are the four pillars of java?
Can we start a thread twice in java?
What is bufferedreader in java?
How the interruptible method gets implemented?
What is a parameter example?
What is a nested class?