package com.hanqi.test; public class Car { //构造一个汽车的属性 private String name; //创建getter和setter方法 public String getName() { return name; } public void setName(String name) { this.name = name; } public void drive() { } } package com.hanqi.test; public c…
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…
///Animal类 package d922A; public class Animal { private String kind; public String getKind() { System.out.println(kind); return kind; } public void setKind(String kind) { this.kind = kind; } public void eat() { System.out.println("I can eat.");…
package animal; public class Animal { //成员属性 private String kind; public String getKind() { return kind; } public void setKind(String kind) { this.kind = kind; } //成员方法 public void eat() { } public void sleep() { } } package animal; public class Fish…
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…
编写一个Animal类,具有属性:种类:具有功能:吃.睡.定义其子类Fish package zhongqiuzuoye; public class Animal { //属性 private String type; public String getType() { return type; } public void setType(String type) { this.type = type; } //功能 public void eat() { } public void sleep…
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)…