package com.itheima;
/** * 9、 有這樣三個類,person、student、goodstudent。
* 其中goodstudent繼承於student,student繼承於person。
* 如何證明建立goodstudent時是否呼叫了person的建構函式?
* 在goodstudent中是否能指定呼叫student的哪個建構函式?
* 在goodstudent中是否能指定呼叫goodstudent的哪個建構函式?
* *
* 答: 1、 在person的建構函式中隨便輸出一句話,建立goodstudent的物件,
* 如果輸出是那一句話,就會證明建立goodstudent時呼叫了person的建構函式。
* 2、在goodstudent的建構函式最開始寫上super(a);就可以呼叫student的有乙個引數的建構函式
* 3、因為goodstudent可以指定呼叫student的確定的建構函式,student可以指定呼叫person的確定的
* 建構函式,所以可以在goodstudent中指定呼叫person的建構函式。
* @author idea
* */
public class test9 }
class person
//person的有參建構函式
public person(string a)
}class student extends person
student(string a)
}class goodstudent extends student
}
黑馬基礎測試5
package com.itheima 5 寫出以下 執行結果,分析為什麼?沒有分析結果不得分 public static void main string args author 劉江濤 public class test5 執行結果 abc false 分析 1 語句 string s abc ...
黑馬基礎測試6
package com.itheima 6 throw和throws有什麼區別?try catch finally分別在什麼情況下使用?author 劉江濤 public class test6 throw 多方在catch語句塊當中,丟擲異常物件的時候用的,後面跟異常物件。throws 在函式名後...
黑馬基礎測試題(一)
1 從鍵盤接受乙個數字,列印該數字表示的時間,最大單位到天,例如 鍵盤輸入 6,列印6秒 鍵盤輸入 60,列印1分 鍵盤輸入 66,列印1分 6秒 鍵盤輸入 666,列印11分 6秒 鍵盤輸入 3601 列印1小時1 秒2 編寫乙個函式,函式內輸出乙個字串,並在主函式內呼叫它。3 為什麼需要配置 p...