What is an anonymous class?
An anonymous class is a local class without a name. An
anonymous class is defined and instantiated in a single
succinct expression using the new operator.
Example:
class popcorn{
public void eat(){
syso("popcorn is sweet");
}
public void m1(){
syso("popcorm method");
}
class sample{
public static void main(String args[]){
popcorn p = new popcorn(){
public void eat(){
syso("popcorn is so hot");
}
};
p.eat();
p.m1();
}
}
| Is This Answer Correct ? | 17 Yes | 3 No |
Explain the importance of thread scheduler in java?
What does || || mean in math?
Is there any difference between synchronized methods and synchronized statements?
What do you mean by platform independence?
What is subsequence of a string?
What are concepts of OOPS and how are they implemented in Java?
How do generics work?
How to override equals() and hashCode() method in java?
Does 'true' and 'false' are keywords?
What is difference between protected and private?
Why we use static and synchronized in method for single thread model example: public static synchronized add(){}
What is an Exception ?