【无标题】

class People{
    public double x;
    public void setX(double x){
       this.x=x;
    {
    public double getDoubleX(){
       return x;
    }
}
class Student extends People{
    int x;
    public int getX(){
       //x=20.56;
       return x;
    }
}
public class Example5_3{
  public static void main(String args[]){
      Student stu=new Student();
      stu.x=98;
      System.out.println("对象stu的值是:"+rtu.getX());
      //stu.x=98.98;
      stu.setX(98.98);
      double m=stu.getDoubleX();
      System.out.println("对象stu隐藏的值是:"+m);
  }
}
package enbland.people;
import american.people.Son;
import japan.people.Grandson;
public class Example5_1{
     public static void main(String args[]){
         Son son=new Son();
         Grandson grandson=new Grandson();
         son.height=180;
         son.hand="一双大手";
         grandson.height=155;
         grandson.hand="一双小手";
         grandson.foot="一双小脚";
         String str=son.getHand();
         System.out.printf("儿子:%s,%d\n",str,son.height);
         str=grandson.getHand();
         System.out.printf("孙子:%s,%s,%d\n",str,grandson.foot,grandson.height);
     }
}
class A {
    double f(float x,float y){
        return x+y;
    }
    public int g(int x,int y){
        return x+y;
    }
}
class B extends A {
    double f(float x,float y){
        return x*y;
    }
}
public class Example5_4{
    public static void main(String args[]) {
        B b = new B();
        double result = b.f(5, 6);
        System.out.println("调用重写方法得到的结果:" + result);
        int m = b.g(3, 5);
        System.out.println("调用继承方法得到的结果:" + m);
    }
}
public class Student{
    int number;
    System name;
    Student(){
    }
    Sudent(int number,String name){
        this.number=number;
        this.name=name;
    }
    public int getNumber(){
        return number;
    }
    public String getName(){
        return name;
    }
}
public class Example5_7{
    public static void main(String args[]){
        Average aver=new Average();
        aver.n=100.5678;
        double result1=aver.f();
        double result2=aver.g();
        System.out.println("result1="+result1);
        System.out.println("result2="+result2);
    }
}
ublic class Example5_9 {
    public static void main(String args[]) {
        People people = new People();
        Anthropoid monkey = people;
        monkey.crySeak("I live this game");
        //monkey.n=100;
        //monkey,comoputer(12,19);
        System.out.println(monkey.m);
        System.out.println(people.m);
        People zhang = (People) monkey;
        zhang.m = 'T';
        System.out.println(zhang.m);
    }
}

public class Example5_13 {

    public static void main(String args[]) {

       Simulator simulator = new Simulator() ;

       simulator. playSound(new Dog()) ;

       simulator.playSound(new Cat());

    }

}

public class Example5_14{

    public static void main(String args[]) {

       AAA a = new AAA() ;

       System.out.println("接口中的常量"+ AAA. M" +AAA. MAX);

       System. out. println("调用on方法(重写的):")

       a.on();

       System.out.println("调用 sum方法(重写的):"+a.sum(12,18));

       System.out.println("调用接口提供的 default 方法"+a.max(12,78); 

       Printable.f();

    }

}

public class A {

    public void f()

    {

        for (int i = 97; i <123; i++)

        {

            System.out.print((char)i);

 

        }

        System.out.println();

    }

 

}

package zimu;

 

public class B extends A {

 

    public void g()

    {

        for (int i = 65; i <91; i++)

        {

            System.out.print((char)i);

 

        }

        System.out.println();

    }

 

}

 

public class C {

 

    public static void main(String[] args) {

    A a=new A();

    a.f();

    B b=new B();

    b.f();

    b.g();

    }

}

class A{

    public int f(int a, int b){

        if(b<a){

        int temp=0;

        temp=a;

        a=b;

        b=temp

        int r=bsa;tr=bx

        0){hile(r!=0)

        b=a;

        a=r;

        r=bs

       =b8a;

    }

    return a;

    }

}

class B extends A{

    public int f(int a,int b) {

        int division = super. f(a,b);

         return (a* b)/division;

}

public class E{

           public static void main (String args[ ]) {

               Aa=new A();

               System.out.println("最大公约数:"+a.f(36,24

               a= new B();

               System.out.println("最小公倍数:" + a.f(36,24

           }

}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值