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 numeric data type?
Why java is said to be pass-by-value ?
How many times finalize method will be invoked? Who invokes finalize() method in java?
Can a class have multiple constructors?
What is a line separator in java?
What is null data type?
What does file separator do in java?
What is the properties class in java programming?
Is it possible to use string in the switch case?
What is the difference between a method and a function in alice?
explain copyonwritearraylist and when do we use copyonwritearraylist?
What are the different http methods?
How is final different from finally and finalize?
Why can't you declare a class as protected?
Can subclass overriding method declare an exception if parent class method doesn't throw an exception?