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
package jiekou1; public interface ShapePara { //定义常量PI final double PI=3.14; //定义抽象方法 //获得图形面积 double getArea(); //获得图形周长 double getCircumference(); } package jiekou1; public class Circle implements ShapePara { //定义成员变量 public double radius; public d
package zhongqiuzuoye; //自己写的方法 public class Rect { public double width; public double height; Rect(double width,double height) //带有两个参数的构造方法,用于将width和height属性初化; { this.width=width; this.height=height; } Rect() //不带参数的构造方法,将矩形初始化为宽和高都为10. { width=10
package com.hanqi.test; public class Rect { ; ; public double getWidth() { return width; } public void setWidth(double width) { this.width = width; } public double getHeight() { return height; } public void setHeight(double height) { this.height = he
//接口 ShapePara package d922B; public interface ShapePara { int getArea(); int getCircumference(); } //圆类 package d922B; public class Circle implements ShapePara { public double radius; private double x; protected double y; Circle(double r) { radius=r
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 com.hanqi.yzljs; public class yzljs { public static void main(String[] args) { final double PI = 3.1415926; double r =3.0; double c =2*PI*r; double s = PI*r*r; System.out.println("圆的周长="+c+" 圆的面积="+s); }