ProghubPH
Вопрос из теста ООП в Java
Java / middle

Что произойдёт в результате выполнения даного кода:

 один вариант
public class Tree { 
    int leavesCount; 
    String treeName; 
    Tree (int leaves){ 
        this.leavesCount = leaves; 
        System.out.println("int constructor"); 
    } 
    Tree (String treeName, int leaves){ 
        this(leaves); 
        this(treeName); 
        System.out.println("(String, int) constructor"); 
    } 
    Tree (String treeName){ 
        this.treeName = treeName; 
        System.out.println("String constructor"); 
    } 
    Tree () { 
        this("huge tree", 50000); 
        System.out.println("constructor without parameters"); 
    } 
    void printLeavesCount(){ 
        System.out.println("leavesCount = " + leavesCount + " treeName = " + treeName); 
    } 
    public static void main (String[] args) { 
        Tree tree = new Tree(); 
        tree.printLeavesCount(); 
    } 
} 
Ошибка времени выполнения
Вывод: int constructor String constructor (String, int) constructor constructor without parameters leavesCount = 50000 treeName = huge tree
Вывод constructor without parameters leavesCount = 50000 treeName = huge tree
Вывод: int constructor constructor without parameters leavesCount = 50000 treeName = huge tree
Ошибка компиляции