– 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;定义一个主类A,其所在的包也为bzu.info.com,在A中生成一个Cylinder对象,并输出其体积。编译并运行该类。

– 试着改变求体积方法的访问权限,查看并分析编译和运行结果

(1)代码

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

(2)运行截图

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

问题二:

– 把Cylinder类和A类置于不同的包中,通过对求体积方法设置不同的访问权限,查看并分析编译和运行结果

(1)代码

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

(2)运行截图

Part 4 Package与Import 定义一个圆类(Circle),其所在的包为bzu.info.software;定义一个圆柱类Cylinder,其所在的包为bzu.info.com;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-04-17
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
猜你喜欢
  • 2021-09-12
  • 2021-12-05
  • 2022-01-09
  • 2021-11-04
  • 2021-04-14
  • 2022-12-23
  • 2021-05-21
相关资源
相似解决方案