Question: JAVA 2. [15 marks] Suppose you need to design classes for three dimensional geometric Shape 3D shapes such as Sphere and Cube. The shapes can

JAVAJAVA 2. [15 marks] Suppose you need to design classes for three

2. [15 marks] Suppose you need to design classes for three dimensional geometric Shape 3D shapes such as Sphere and Cube. The shapes can be either not filled or filled. Like any -Silled:boolean other 3D shapes, these shapes have cinterface Shape 3D(filled boolean) geometric properties such as surface area Compare To isFiledo:boolean and volume. Define a subclass Sphere with compareTo(o:Ey int #getArea() double all attributes and methods described in the #getVolume(/double UML diagrams below._Implement the abstract methods getArea(, getVolume and compare To inside the Sphere subclass. Sphere Volumes of two Sphere objects are -radius:double compared in compare Too method. Also, +Sphere(radius:double, filled.boolean) override the toString inside Sphere to show HoString() String all the attributes of superclass and subclass. Formula: Surface area of Sphere = 4 *PI * radius radius, volume of Sphere = (4/3) PI* radius radius * radius. 3. [5 marks] We can't create objects of an abstract class, but we can use abstract class or interface as a type - Justify this statement with appropriate example and context. 4. [5 marks] Explain explicit and implicit type casting of objects with examples in the context of polymorphism. 5. [3 marks] Suppose you are trying to copy first 10 lines of text from 'students.txt file to copy.txt' file. Write a code segment (not a complete program) with appropriate exception handling measures so that the program does not crash at runtime

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!