What is the use of anonymous inner classes ?
Answer Posted / ashokkumar
Anonymous classes
1.These are one type of inner class that having no mame.
2.The syntax will come like
class a
{
public void mymethod ();
}
class b
{
a obja = new a(){//the anonymous class starts here
public void mymethod (){ //have to implement the methods of
//class 'a'
return "here we are implementing mymethod of class 'a'"
}
}; //when finishing anonymous classes we have to put";"
}
3.Here the anonymous class is consider as a sub class of
class 'a'.We can access all the variables and methods of
super class 'a' through the anonymous block,except local
variables,including private variables.
4.Through anonymous classes we can create instance for
Interfaces.
| Is This Answer Correct ? | 19 Yes | 16 No |
Post New Answer View All Answers
what is the difference between the methods sleep() and wait()? : Java thread
Is final static java?
Describe the process as to how substring() methodology mechanisms in java.
Explain the difference between extends thread vs implements runnable in java?
Implementations of set interface?
Explain the use of volatile field modifier?
What is string immutability?
What is consumer interface?
What is io stream in java?
Explain scope or life time of local variables in java?
What are green threads in java?
Which is bigger float or double java?
What is a parameter in java?
Why destructor is not used in java?
Difference between string, stringbuffer and stringbuilder?