The code creates a class named Anonymous with a main method. When the main method is executed, an instance of an anonymous inner class Demo is created using the new keyword.
The anonymous class has a constructor that simply prints the message "Constructor" to the console. Therefore, when the anonymous inner class instance is created, the constructor is called and the message "Constructor" is printed to the console.
public class Anonymous { public static void main(String[] args) { new Demo(); } } class Demo { Demo() { System.out.println("Constructor"); } }
Constructor
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions