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
Name some classes present in java.util.regex package.
What is tcp and udp?
What do you understand by java?
What is an example of a conditional statement?
If goto and const is reserve words than why it is not work in java?
What is int short for?
What is the collection interface?
Do extraneous variables affect validity?
Explain the features of java?
How do you initialize an arraylist in java?
Difference between ‘is-a’ and ‘has-a’ relationship in java?
What are the four corner stones of oop?
Can we use synchronized block for primitives?
What is stack explain?
What is tree node in java?