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
Can we override final method?
What is the difference between overriding & overloading?
What's the access scope of protected access specifier?
Give an example of use of pointers in java class.
What is Garbage Collection in Java
What if static is removed from main method?
Why are lists ordered in java?
What is difference between classpath and path variables in java?
What is a constructor overloading in java?
Why are the destructors for base class and derived class called in reverse order when the program exits
What is the difference between @before and @beforeclass annotation?
What is encapsulation in java?
What are 4 pillers of object orinted programming?
Can long be null in java?
What is singletonlist in java?