Compiler Error J0040

Cannot define a method body for abstract/native methods

The compiler detected a method body defined immediately following the corresponding declaration of an abstract or native method. An abstract method must have it's implementation code defined in a subclass. Native methods are implemented using code from a native language such as C++.

The following example illustrates this error:

public abstract class Simple{
   abstract void method1(){
      //Do something here
   }//error: abstract methods are implemented in subclasses
}

Methods declared within an interface are implicitly abstract. As such, this error can also occur when you attempt to define a method body in an interface. The following code illustrates this scenario:

public interface Simple {
   
   public void method1() {
      // error: must define this method body
      // in a class that implements the 
      // 'Simple' interface
   }
}