Skip to content
Advertisement

How can I implement interface correctly?

I am doing homework of making a simple calculator using java and interface in java. but the class that implements java gives error saying

JavaScript

here is the code

JavaScript

Advertisement

Answer

There are a couple of issues here.

First, since BasicCalculator is a public class, it needs to be defined in its own file named BasicCalculator.java.

Second, the method names in BasicCalculator must match those you’re trying to implement in calcualte – i.e., sub, mul and div instead of subtract, multiply and division.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement