What class files will be created during the compilation of the following code?

public class Count {
    class A { }

    public static void main(String[] args) {
        Object obj = new Object() {
            { System.out.println(this); }
class Count$1 { }
Files for inner classes are named Outer$Inner, for anonimous classes - Outer$1, Outer$2, ... But $ is a legal symbol for identifiers and class Count$1 was already declared. Therefore, obj variable will contain a pointer to the anonimous class Count$2. So, 4 files will be created.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes