10. สิ่งผิดปกติ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 10-16  ตัวอย่างการแทนเมท็อดของคลาสแม่ที่มีการโยนสิ่งผิดปกติ
public class Super {
  public void p() {
    ...
  }
  public void q() throws FileNotFoundException {
    ...
  }
  public void r() throws IOException {
    ...
  }  
public class Sub extends Super {
  @Override public void p() throws IOException { // ผิด แม่ไม่ได้โยน 
    ...
  }
  @Override public void q() throws IOException { // ผิด โยนผิดแบบ 
    ...
  }
  @Override public void r() throws FileNotFoundException { //ถูกต้อง 
    ...
  }  
©2009 S.Prasitjutrakul