An abstract method cannot be static because the abstract method must be overridden i.e, body of the abstract method must be defined before invocation.
See the wrong code below:
Here the abstract method earnings() is declared as static. An abstract method must be non-static. So the correct code is:
See the wrong code below:
public abstract class Employee
{
public static abstract double earnings(); // error
}
Here the abstract method earnings() is declared as static. An abstract method must be non-static. So the correct code is:
public abstract class Employee
{
public abstract double earnings(); // no error now
}
I don't want to be belittling your post, but this is too mundane even for Java 101 class. All the information expressed here is already in the compiler error message. You should be aiming for posts more useful than that.
ReplyDelete