阿摩線上測驗 登入

試題詳解

試卷:104年 - SCJP 1-50#41416 | 科目:OJCP(SCJP)

試卷資訊

試卷名稱:104年 - SCJP 1-50#41416

年份:104年

科目:OJCP(SCJP)

第43題 Given: 1. class Plant{ 2. private String name; 3. public Plant(String name){this.name = name;} 4. public String getName(){return name;} 5. } 6. public class Tree extends Plant{ 7. public void growFruit(){} 8. public void dropLeaves(){} 9. } What statement is true?
(A) The code will compile without changes.
(B) The code will compile if public Tree(){Plant();} is added to the Tree class. SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 23
(C) The code will compile if public Plant(){Tree();} is added to the Plant class.
(D) The code will compile if public Plant(){this("fern");} is added to the Plant class.
(E) The code will compile if public Plant(){Plant("fern");} is added to the Plant class.
正確答案:登入後查看