抽象クラスとインタフェースの実装、抽象メソッドの作成と実装を学ぶ

1132 ワード

package com.chouxiang;

/**
 *           ,          
 *  Father    ,Father_intface     ,Son Father        Father_intface。
 *
 */
public  class Son extends Father implements Father_intface{


	@Override
	public void setName(String name) {//           
		this.name=name;
		
	}

	@Override
	public void setAge(int age) {    //           
		this.age=age;
		
	}
	
	
	

	@Override
	public void eat() {             //          
		System.out.println("eat");
		
	}

	@Override
	public void walk() {
		System.err.println("run");  //          
		
	}
	
	public static void main(String[] args){
		Son son_1= new Son();        //new   Son  
		Father_intface son_2= new Son();//                 ,                     
	}

	

}


//   
abstract class  Father {
	protected String name;
	protected int age;
	
	public abstract void setName(String name);//      abstract    
	public abstract void setAge(int age);  
	
	public static void main(String[] args){
		
	}
	
}



//  
interface Father_intface{
	public abstract void eat();             //       public abstract    
	                void walk();
	
    
}