Answer Posted / venki
3) Anonymous classes:
1. A class which doesn’t have any name is called anonymous class and which is a type of inner class. It can be either member class or local class.
2. It is a sub class that extends a class or implements an interface but not both. It can implement only one interface.
3. These are used where implementation of methods various from one object to another object. Anonymous class is final class.
4. public class Demo{
A a=new A();
a.m1();
A 1=new A(){ void m1(){ --- }};
a1.m1();
}
On compiling this above program the java compiler generates A.class, Demo.class and Demo$1.class (Anonymous class).
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is meant by class?
What is method overloading with type promotion?
What is the difference between preparedstatement and statement in java?
Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?
How do you differentiate abstract class from interface?
Why is java multithreaded?
Can an interface have a constructor?
What is the size of integer?
What is a nested class?
Why char array is preferred over string for storing password?
Give few difference between constructor and method?
How we can run a jar file through command prompt in java?
What is overriding in java?
What is meant by main method?
describe synchronization in respect to multithreading? : Java thread