Yahoo奇摩 網頁搜尋

  1. b = (A)b; b已經向上轉型成A,向下轉型成B則要顯性轉換 b = (B)(A)b; a = (B)a; a不可能向下轉型成B,除非a儲存的是B物件

  2. 子類別的建構子如果沒有指定呼叫父類別的哪個建構子,則預設呼叫父類別的無引數建構子。 public CRectangle11_1(int w,int h) { width=w; height=h; } 相當於 public CRectangle11_1(int w,int h) { super(); width=w; height=h; } 但是類別CShape11_1中沒有無引數建構子public...

  3. 執行結果是 Son GrandFather class Son class Daughter 明顯是答案給錯 System.out.println(f2.getName()); Son類別中name指定為Son,所以回傳Son。 System.out.println(f3.getName()); Daughter...

  4. ... { public double area() { return 0d; } } class CCircle extends CSharp { private double radius; public CCircle(double radius...

  5. 因為GraphicsEnvironment 係abstract唔可以直接建立類型的實例。

  6. Intent i = new Intent("android.intent.action.CALL",Uri.parse("tel:"+num)); 上面改成 Intent i = new Intent("android.intent.action.CALL",Uri.parse("skype:"+num));

  7. import java.awt.event.*; import javax.swing.*; public class EasyCard extends JApplet implements ActionListener { private static final...

  8. ....out.println(count); } } B類別複寫 public class TestB extends TestA { public void show() { this.count = 20; System.out.println(this.count...

  9. ... = workerNumber; } } class SalaryWorker extends Work { private int annualSalary; public SalaryWorker...