Create a class named Square that contains data fields for height, width, and surfaceArea, and a method named computeSurfaceArea(). Create a child class named Cube. Cube contains an additional data field named depth, and a computeSurfaceArea() method that overrides the parent method. Write an application that instantiates a Square object and a Cube object and displays the surface areas of the objects. Save the files as Cube.java, Square.java, and DemoSquare.java.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 1E: Create an application class named LetterDemo that instantiates objects of two classes named Letter...
icon
Related questions
Question

Using java, solve the problem.

Create a class named Square that contains data fields for height, width, and
surfaceArea, and a method named computeSurfaceArea(). Create a child class named
Cube. Cube contains an additional data field named depth, and a
computeSurfaceArea() method that overrides the parent method. Write an application
that instantiates a Square object and a Cube object and displays the surface areas of
the objects. Save the files as Cube.java, Square.java, and DemoSquare.java.
Transcribed Image Text:Create a class named Square that contains data fields for height, width, and surfaceArea, and a method named computeSurfaceArea(). Create a child class named Cube. Cube contains an additional data field named depth, and a computeSurfaceArea() method that overrides the parent method. Write an application that instantiates a Square object and a Cube object and displays the surface areas of the objects. Save the files as Cube.java, Square.java, and DemoSquare.java.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT