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 static import in java?
Explain the available thread states in a high-level?
What is command line argument
What about main thread in java?
Can we have static methods in an interface?
Explain parallel processing in java8?
Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.
What loop means?
Can we assign the reference to this variable?
What is Classloader in Java?
How do you sort data in java?
How many bytes is string in java?
If two threads have same priority which thread will be executed first ?
What do you know about the garbage collector in java?
What is java jit compilers?