InterviewSolution
| 1. |
If You Compile A File Containing Inner Class How Many .class Files Are Created And Are All Of Them Accessible In Usual Way? |
|
Answer» If a inner class enclosed with an outer class is compiled then one .class file for each inner class and a .class file for the outer class is created. class EnclosingOuter { class Inner{ } } If you compile the above code with COMMAND: % JAVAC EnclosingOuter.java TWO files will be created. THOUGH a separate inner class file is generated, the inner class file is not accessible in the usual way. EnclosingOuter.class EnclosingOuter$Inner.class If a inner class enclosed with an outer class is compiled then one .class file for each inner class and a .class file for the outer class is created. Example: class EnclosingOuter { class Inner{ } } If you compile the above code with command: % javac EnclosingOuter.java Two files will be created. Though a separate inner class file is generated, the inner class file is not accessible in the usual way. EnclosingOuter.class EnclosingOuter$Inner.class |
|