What is an anonymous class?
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 |
What is parsing and its types?
transaction attributes ?
How do you define a set in java?
Is it possible to declare abstract class as final?What happens if we do so?
Define immutable object?
What is pass by value?
how to deploy apache tomcat server to weblogic server in java
Can we use this () and super () in a method?
Why does java not allow multiple public classes in a java file ?
how system.out.println() works?
What is the use of singleton?
Can sleep() method causes another thread to sleep?