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 |
What is the default size of set in java?
Can we override the private methods?
What is a parameter in java?
What are different type of access modifiers?
What is anonymous inner class?
Can list be null in java?
What is an infinite loop? How infinite loop is declared?
Is it possible to compare various strings with the help of == operator? What are the risks involved?
What is finalize()? Is finalize() similar to a destructor?
How is the marker interface used in Java?
What is a parent class in java?
What are the difference between composition and inheritance in java?