5.14接口练习

接口练习

package pro;



public class pro2 {
public void getspeed(IUSB i){
i.speed();
}
public static void main(String[] args) {
pro2 c=new pro2();
usb1 u1=new usb1();
usb2 u2=new usb2();
usb3 u3=new usb3();
c.getspeed(u1);
c.getspeed(u2);
c.getspeed(u3);
}
}
interface IUSB{
void speed();
}
class usb1 implements IUSB{


@Override
public void speed() {
System.out.println("sudu");
}

}
class usb2 implements IUSB{
public void speed(){
System.out.println("sudu");
}
}
class usb3 implements IUSB{
public void speed(){
System.out.println("sudu");
}

}



package pro;
interface IMotocar{
void method1();
}
interface ICar extends IMotocar{
void method2();
}
interface ITruck extends IMotocar{
void method3();
}
interface IStation_waggon extends ICar,ITruck{
void method4();
}
class Mycar implements IStation_waggon{
public void method4() {
System.out.println("shixian1");

}
public void method2() {
System.out.println("shixian2");

}
public void method1() {
System.out.println("shixian3");

}
public void method3() {
System.out.println("shixian4");

}

}
public class pro1 {
public static void main(String[] args) {
Mycar m=new Mycar();
m.method1();
m.method2();
m.method3();
m.method4();
}

}


package pro;


interface Imammal{
public abstract void speak();
public abstract void eat();
public abstract void run();
int m=1;
int mm=2;
}
class A implements Imammal{
public void speak(){
System.out.println("liu");
}
public void eat() {

}
public void run() {

}
}
abstract class B implements Imammal{
public void speak(){
}
}
public class proo {


public static void main(String[] args) {
Imammal d=new A();
d.speak();
A a=new A();
a.speak();


}


}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值