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
Why can't we override private static methods?
What are the features in java?
What is java argument list?
What is meant by inheritance and what are its advantages?
What is object in java?
What are access specifiers available in java?
What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?
Why is stringbuffer faster than string?
What does the three dot emoji mean?
What is the difference between overriding & overloading?
How do you create a method in java?
What is the static import?
How to Sort Strings which are given in List and display in ascending order without using java api.
What happens if an exception is throws from an object's destructor?
Can we create an object of static class in java?