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
What is default constructors?
Difference between doublesummarystatistics, intsummarystatistics and longsummarystatistics ?
What is a text string?
how would you implement a thread pool? : Java thread
If a class is declared without any access modifiers, where may the class be accessed in java programming?
What is the r character?
What type of variable is gender?
How do I remove a character from a string in java?
What is the meaning of variables in research?
When can you say a graph to be a tree?
what is use of functional interface in java 8?
Why java is object oriented?
Why is the type for real numbers called double?
What is meant by collection in java?
How do you calculate square roots?