Which executed first, The parent or the child constructor?
问题 I've put this code in the compiler package com.employer.constractor; public class ConstractorDemo extends A{ public ConstractorDemo(){ System.out.print("Demo"); } public static void main(String[] args){ new ConstractorDemo(); } } class A { A(){ System.out.print("A"); } } And it gave "ADemo" why? I'll appreciate any detailed answer for this case and mention how compiler will deal exactly with that 回答1: The child constructor is invoked first. The first line in the child constructor will be a