java-抽象类及接口(学习代码)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/BODOA/article/details/79978986

父类:Tlephone

package java抽象类;

public abstract class Tlephone {
  public abstract void call() ;
	public abstract void message();  
  
}


接口类: IplayGame
package java抽象类;
//接口类
public interface IplayGame {
public void play() ;
	

}
子类:
package java抽象类;

public class Smartphone extends Tlephone implements IplayGame{  //继承父类和接口类

	@Override
	public void call() {
		// TODO Auto-generated method stub
System.out.println("yuying");
	}

	@Override
	public void message() {
		// TODO Auto-generated method stub
System.out.println("yuying");
	}

	@Override
	public  void play() {
		// TODO Auto-generated method stub
		System.out.println("wanyouxi");
	}

}
package java抽象类;

public class Cellphone extends Tlephone {

	@Override
	public void call() {
		// TODO Auto-generated method stub
System.out.println("jianpan");
	}

	@Override
	public void message() {
		// TODO Auto-generated method stub
System.out.println("jianpan");
	}

}
接口子类:
package java抽象类;

public class Psp implements IplayGame {

	@Override
	public void play() {
		// TODO Auto-generated method stub
		System.err.println("psp");
	}

}




阅读更多

没有更多推荐了,返回首页