Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

JAVAimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago