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 technique is carried out to find out if a particular string is empty?
How do you compare objects in java?
what are Hostile Applets?
If you are given the name of the function at run time how will you invoke the function?
Why set do not allow duplicates in java?
Can we use catch statement for checked exceptions?
Is array passed by reference in java?
What is final variable?
What happens when a thread cannot acquire a lock on an object in java programming?
Does hashset allow duplicates in java?
What is the benefit of abstract class?
Explain jdk, jre and jvm?
In which language java is written?
Is java ee a framework?
What are accessor methods in java?