-3

Not sure why my method in the interface is not being overridden.

I get an error message that the class calling the method is not abstract and does not override the method.

Here is the code:

public class Prioritization extends Task {


    public void main(String[] args) {

        setPriority();

        }
}
 interface Priority  {

    public void setPriority();
    public void getPriority();

    final int low = 1;
    final int medium = 50;
    final int high = 100;
}
public class Task implements Priority {

    private int takeOutgarbage;
    private int drinkBeer;
    private int doHomework;
    private String message;




    public void setPriority(){
            takeOutgarbage = 1;
            drinkBeer = 100;
            doHomework = 50;
        }

}

This produces the following error:

Task is not abstract and does not override abstract method getPriority() in Priority public class Task implements Priority {

andrewJames
  • 19,570
  • 8
  • 19
  • 51
  • 1
    You need to provide definition to the getPriority method as well, like you did with setPriority, inside your 'Task' class. Its blueprint is still incomplete without its definition,hence it is still an abstract(clearly depicted by the error you are getting) – nobalG May 23 '21 at 18:07
  • possible duplicate of [Class is not abstract and does not override abstract method in superclass](https://stackoverflow.com/questions/50796804/class-is-not-abstract-and-does-not-override-abstract-method-in-superclass?force_isolation=true) – geocodezip May 23 '21 at 18:08
  • Not to your question, but `public static void main(String[] args) {` - you can't make `main` an instance method. – Elliott Frisch May 23 '21 at 18:09
  • possible duplicate of [error: Class is not abstract and does not override abstract method](https://stackoverflow.com/questions/44706656/error-class-is-not-abstract-and-does-not-override-abstract-method?force_isolation=true) – geocodezip May 23 '21 at 18:11
  • Does this answer your question? [Class is not abstract and does not override abstract method](https://stackoverflow.com/questions/23452097/class-is-not-abstract-and-does-not-override-abstract-method) – azurefrog May 23 '21 at 18:15

1 Answers1

0

You implement setPriority, but not getPriority. You must implement both.

Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413