Answer Posted / sai
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 |
Post New Answer View All Answers
Explain inheritance in java?
How can you set an applet’s height and width as a percentage?
What is string in java is it a data type?
What is return type in java?
What is your platform?s default character encoding and how to know this?
how can i use a nonsynchronized hashtable?
What about abstract classes in java?
How hashmap works in java?
What do you mean by an interface in java?
How is hashcode calculated in java?
What is the purpose of nested class in java?
What are the advantages and disadvantages of object cloning?
Explain heap sort?
What is method overloading in JAVA? Why is it not present in C ?
What is a generic type?