Monday, May 9, 2011



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:

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
}




If the above solutions do not work for you. Please comment below giving your code. I'll try to respond.

1 comments:

  1. 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