LogiQuest
Back to Objects and Classes
11

What is the output of the following program?

public class Main {
    String name = "none";
    Main() { this("default"); }
    Main(String n) { name = n; }
    public static void main(String[] args) {
        System.out.println(new Main().name);
    }
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.