2.19 appreciated that abstract class java

// Telphone.java 
public  abstract  class Cellphone {
     public  abstract  void Call ();
     public  abstract  void Message ();     
} 

// CellPhone.java 
public  class CellPhone the extends Cellphone { 
  @Override 
  public  void Call () { 
    System.out.println ( "keyboard call" ); 
  }   
  @Override   
  public  void Message () {   
    System.out.println ( "keyboard texting" ); 
  } 
} 

//ModernPhone.java 
public  class ModernPhone the extends Cellphone { 
  @Override 
  public  void Call () { 
    System.out.println ( "voice call" ); 
  }   
  @Override   
  public  void Message () {   
    System.out.println ( "Voice texting" ); 
  } 
} 

// Test.java 
public  class the Test {
   public  static  void main (String [] args) { 
    Cellphone TE1 = new new CellPhone (); 
    te1.call ();  
    te1.message ();
    Cellphone TE2 =new ModernPhone();
    te2.call();
    te2.message();
  }  

}

 

Guess you like

Origin www.cnblogs.com/cjh123/p/12329500.html