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
Can we have 2 main methods in java class?
What do you mean by global variable?
Can a class be private in java?
What is meant by local variable and instance variable?
What is the most important feature of java? What is an interface?
Can we override constructors?
How does java pattern compile work?
What is the maximum size of a string in java?
Is char * a string?
What are different access specifiers in java? Explain
Why we cannot override static method?
What is sortedmap in java?
What is final keyword in java? Give an example.
Can we initialize the final blank variable?
Difference between start() and run() method of thread class?