Java Bootcamp – Workbooks and Challenges
)}

Workbook 12.3

From the Java Bootcamp Resources, launch starter.

starter.png

Task 1

The Main class contains two errors.

Line 18: The method getArea() is undefined for the type Shape
Line 19: The method getVolume() is undefined for the type Shape

Define two abstract methods inside Shape to expose these behaviors.

Task 2

It follows that children of Shape must define concrete implementations.

Cylinder must implement the inherited abstract method Shape.getArea()
Cylinder must implement the inherited abstract method Shape.getVolume()

Sphere must implement the inherited abstract method Shape.getArea()
Sphere must implement the inherited abstract method Shape.getVolume()

Use the following table to write equations for area and volume.

ShapeVolume FormulaSurface Area Formula
CylinderV=πr2hV = \pi r^2hA=2πr2+2πrhA = 2\pi r^2 + 2\pi rh
SphereV=(43)πr3V = \left(\frac{4}{3}\right) \pi r^3A=4πr2A = 4\pi r^2

Associated Course: The Complete Java Development Bootcamp
Related Course: The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary
4.7
43 students
5

91%
4

2%
3

0%
2

0%
1

7%
Written Reviews
There are no written reviews yet.