+ 1

Please what is the error in my code

There are two classes that extends from one base class called shape which has one abstract method called area https://code.sololearn.com/cA11a1A91A11/?ref=app

12th Feb 2021, 7:45 PM
Amal Gil
Amal Gil - avatar
4 Respostas
0
line 8: 'shape' should be 'Shape'
12th Feb 2021, 7:54 PM
visph
visph - avatar
0
import java.util.Scanner; abstract class Shape { int width; abstract void area(); } //your code goes here class Square extends Shape { Square (int x) { width = x; } public void area() { System.out.println(width * width); } } class Circle extends Shape { Circle (int y) { width = y; } public void area() { System.out.println(Math.PI * width * width); } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } }
12th Feb 2021, 8:02 PM
**🇦🇪|🇦🇪**
**🇦🇪|🇦🇪** - avatar
0
why here when i used tge super keyword wich refers to the width in the base class is not working
12th Feb 2021, 8:47 PM
Amal Gil
Amal Gil - avatar
0
super keyword does not work with Abstract Class , if that was your question
12th Feb 2021, 9:10 PM
**🇦🇪|🇦🇪**
**🇦🇪|🇦🇪** - avatar