1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Westkost [7]
4 years ago
9

Although saying "Cylinder IS A Circle" doesn't make sense, it can be implemented in Java using inheritance in a legitimate way.

Implement Circle and Cylinder classes with fields, constructors and methods required to demonstrate all aspects of legitimate inheritance.
Computers and Technology
1 answer:
allochka39001 [22]4 years ago
8 0

Answer:

I've included in the codes the area to circle and volume to cylinder. The Volume method that was used, area() to compute, the volume of cylinder which shows that cylinder is an expansion of circle with an extra dimension (height)

Explanation:

Temp is tester class

public class Temp {

   public static void main(String[] args) {

       Circle c = new Circle(7);

       System.out.println("Area of circle with radius 7 is "+c.area());

       Cylinder c1 = new Cylinder(7,10);

       System.out.println("Cylinder volume with radius 7 and height 10: "+c1.volume());

   }

}

----------------------------------------------------------------------------------------------------

class Circle{

   int radius;

   Circle(int r){

       radius=r;

   }

   double area(){  //area of circle

       return 3.14*radius*radius;

   }

   public int getRadius() {

       return radius;

   }

   public void setRadius(int radius) {

       this.radius = radius;

   }

}

class Cylinder extends Circle{

   int height;

   Cylinder(int r, int h){

       super(r);

       height=h;

   }

   double volume(){  //volume of cylinder

       return area()*height;

   }

   public int getHeight() {  //accessor

       return height;

   }

   public void setHeight(int height) {  //mutator

       this.height = height;

   }

}

You might be interested in
Which element is located on the top left of the Word screen?
victus00 [196]
The <span>element located on the top left of the Word screen is the Quick Access Toolbar.  </span>On the quick access toolbar, you can find some of the common functions that you will need to use on a regular basis, it contains commands that are used most often, for example Redo, Undo and Save etc.
7 0
3 years ago
The rmdir command (with no options) can only remove empty directories <br> a. True <br> b. False
Anni [7]
True. It will say "directory not empty"
3 0
3 years ago
Obtain the Truth tables to the following Boolean expressions, and prove the solution's in sagamath
nlexa [21]
The answer to your question is b☺️☺️
4 0
3 years ago
How to create a shortcut to a website on your desktop?.
dusya [7]

Answer:

open web browser, open your favorite website or webpage, right click on the web address located in the address bar of your web

3 0
2 years ago
What are the characteristics of computer. Explain any one​
Pachacha [2.7K]

Answer:

<h3>Your answer will be on the picture above..</h3>

Explanation:

Hope it helps you..

Y-your welcome in advance..

(;ŏ﹏ŏ)(ㆁωㆁ)

7 0
3 years ago
Read 2 more answers
Other questions:
  • What program is considered the industry standard for digital graphics and image editing?
    7·2 answers
  • Which asset would be helpful in assessing a web or UI designer’s skills?
    13·2 answers
  • While you work on the customer’s printer, he continues chatting about his network and problems he’s been experiencing. One compl
    14·2 answers
  • supppose we already have a list called words, containing all the words(i.e., string).Write code that produce a sorted list with
    14·1 answer
  • To analyze data from a survey, you use a spreadsheet to calculate the percent of students who prefer corn over broccoli or carro
    11·2 answers
  • Let’s use that simple branch instruction to do the following: Load the two words declared in the data statement shown to the rig
    14·1 answer
  • Ryan is working on the layout of his web page. He needs to figure out where the title, links, text, and images should go. Which
    13·2 answers
  • Please help me!!!
    8·2 answers
  • 5. Write<br>the<br>steps.<br>open<br>MS-<br>powerpoin<br>to<br>​
    11·1 answer
  • Write getfirstroot and getsecondroot to return the first and second roots. return a domain_error is there is no first or second
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!