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 convert stringbuilder to string in java?
What is the final field modifier?
Can we able to pass objects as an arguments in java?
Can a final variable be null?
Is array an object in java?
Is an array a vector?
What is generic class?
Is it necessary for the port addresses to be unique? Explain with reason.
What is :: operator in java?
Which java version is latest?
describe synchronization in respect to multithreading? : Java thread
Can we have any code between try and catch blocks?
Can we have try without catch block?
Write a program to solve producer consumer problem in java?
Is java se open source?