package zhongqiuzuoye; public class Car { String brand; public void drive() {} } package zhongqiuzuoye; public class Aodi extends Car{ public double price; public String model; public double speed; public Aodi(double price,String model,double speed)…
package b; public class Car { public final static Car pinpai=new Car(); public static Car instance() { return pinpai; } public void drive() { System.out.println("请安全驾驶!"); } } package b; public class Aodi extends Car { private String price; priv…
public class A { private int a=1; public int getA() { return a; } public void setA(int a) { this.a = a; } public void a() { System.out.println("a="+a); } public void c() { System.out.println("a-1="+(a-1)); } } package jicheng; public c…
22.编写一个类A,该类创建的对象可以调用方法showA输出小写的英文字母表.然后再编写一个A类的子类B,子类B创建的对象不仅可以调用方法showA输出小写的英文字母表,而且可以调用子类新增的方法showB输出大写的英文字母表.最后编写主类C,在主类的main方法 中测试类A与类B. package jicheng; public class A { public void showA() { System.out.println("asdfsdf"); } } package jic…
这个题让我更加明白了类创建对象的实质 代码中用到:1.对象作形参;2.对象作返回值 以下用代码具体分析: class Point1{ public double x; public double y; Point1(){} public Point1(double x,double y){ this.x=x; this.y=y; } public void show(){ System.out.println("x="+x+","+"y="+y)…
Print类: package com.bao; public class Print { int g,s,b; void outPut() { for(int i=100;i<1000;i++) {g=i%10; s=i/10%10; b=i/100; if(ggg+sss+bbb==i) {System.out.println(i);} } } } 主类E: package com.bao; public class E { public static void main(String[]…
package a; public class Father { public String name; private int age; public Father(String name) { this.name=name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Father(int age) { super(); this.age = age;…
i汽车类 package com.lanxi.demo2_3; public class Car { private String name; private int price; @Override//重写toString方法 public String toString() { return "Car [name=" + name + ", price=" + price + "]"; } public Car() {//创建无参构造方法 s…
package b; public interface CanFly { public void fly(); } package b; public class FeiJi implements CanFly { @Override public void fly() { System.out.println("飞机 化工能源飞行"); } } package b; public class Niao implements CanFly { @Override public void…
package zimu; 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)…