Hi
public class TestClass
{
public static void main(String[] args)
{
TestClass t = new TestClass();
}
private static void testMethod(){
abstract class TestMethod{
int a;
int b;
int c;
abstract void implementMe();
}
class DummyClass extends TestMethod{
void implementMe(){
}
}
DummyClass dummy = new DummyClass();
}
}
I found out that the above piece of code is perfectly legal in Java. I have the following questions.
- What is the use of ever having a class definition inside a method?
- Will a class file be generated for DummyClass
- Its hard for me to imagine this concept in an Object Oriented manner. Having a class definition inside a behavior. Probably can someone tell me with equivalent real world examples.
- Abstract classes inside a method sounds a bit crazy to me. But no interfaces allowed. Is there any reason behind this?
Thanks
Edit: Added one more question regarding Abstract method classes.