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
How is tree Mirroring implemented?
Which package is imported by default?
Explain jdk, jre and jvm?
Explain when noclassdeffounderror will be raised ?
What is a literal coding?
What do you mean by global variable?
What is a newline character in java?
What is string example?
What is enhanced loop in java?
Can we use return in constructor?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
How to invoke external process in java.
What is the difference between Java and C++?
What are the data types supported by java?
what is the volatile modifier for? : Java thread