[Solved] Implementation OOP in JAVA


Any of the following solutions will work:

  1. Remove the keyword, public from the definition of the classes, Circle and Square
  2. Write the classes, Circle and Square as they are (i.e. with public keyword) in separate files.

The reason is that Java supports only one public class in a source file.

A couple of more points:

A. You should instantiate Circle and Square as follows:

Shape circle = new Circle(true, 10);
Shape square = new Square(true, 10);

B. As per your assignment (in the picture), you are supposed to use boolean but you have used Boolean. Note that it doesn’t have anything to do with the compilation errors.

1

solved Implementation OOP in JAVA