Javaの継承についてお聞きしたいです
クラスXを継承したサブクラスYの引数ありコンストラクタを呼び出した時
this();が記述されていた場合、暗黙的なsuper();は呼ばれないのでしょうか?
java
1 2import java.util.*; 3 4class X { 5 X(){ 6 System.out.println(1); 7 } 8 X(int x){ 9 this(); 10 System.out.println(2); 11 } 12} 13 14class Y extends X{ 15 Y() { 16 super(6); 17 System.out.println(3); 18 } 19 Y(int y){ 20 **ここで暗黙的なsuper()は呼ばれないのか** 21 this(); 22 System.out.println(4); 23 24 } 25} 26public class Main { 27 public static void main(String[] args) throws Exception { 28 new Y(5); 29 } 30} 31 32 33 34
1 2 3 4
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。