ctepac File Edit Format View Help public class Triangle extends Shape t private
ID: 3871825 • Letter: C
Question
ctepac File Edit Format View Help public class Triangle extends Shape t private double side1; private double side2; private double side3; public Triangle) f this(1.e, 1.e, 1.0); public Triangle(double side1, double side2, double sidea) ( setside1 (side1); setside2(side2); setside3 (side3); public double getArea) ( // Heron's formula double p - (getside1) + getside2) getside30)/2.8 double area Math.sqrt(p* (p-getside1())*(p-getside2()) (p-getside3O) return area; public string tostring) ( return super.tostring)I'n a Triangle" ..-Getters/setters-..-ee... public double getside1) f return side1; public void setside double side) c this.side1 side1; public double getside2) ( return side2; public void setside2(double side2) ( this.sidez side2 public double getside3 t return sidea public void setsides(double side3) ( this,sidea side3; 0 Type here to searchExplanation / Answer
Hi,
1. Since circle extends Shape, the relationship type is 'IS-A' i,e circle IS A type of shape
2. Shape is the parent and Circle is the child
3. Circle IS A type of shape
4.EXTENDS is keyword that indicates a IS A relationship
5. a solid line is drawn from the child class that is Circle with a closed, unfilled arrowhead (or triangle) pointing to parent i.e shape class
6.Rectangle class not shown in pictures
7.Since numShapes is declared as static int, its a static member, it can be accessed as Shape.numShapes
8.To give the subclasses access we can make them protected
Thumbs up if this was helpful, otherwise let me know in comments.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.