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


Please Help Members By Posting Answers For Below Questions

Can we override final method?

555


What is the difference between overriding & overloading?

554


What's the access scope of protected access specifier?

528


Give an example of use of pointers in java class.

556


What is Garbage Collection in Java

599






What if static is removed from main method?

562


Why are lists ordered in java?

534


What is difference between classpath and path variables in java?

541


What is a constructor overloading in java?

510


Why are the destructors for base class and derived class called in reverse order when the program exits

1694


What is the difference between @before and @beforeclass annotation?

524


What is encapsulation in java?

611


What are 4 pillers of object orinted programming?

570


Can long be null in java?

538


What is singletonlist in java?

500