Hope you already got your answer by now if not then it may be useful for you.
I have encountered a similar question asked in a forum.
The reason why abstract
and strictfp
can't sit together in the method declaration is because abstract
says the method must not be implemented by the current class and it must be implemented by the concrete subclass and strictfp
says the method should be implemented (should have a body) by the class where strictfp
is used. So in this case both key words contradict with each other hence both are not allowed together in method declarations.
But it is absolutely legal to use abstract
and strictfp
before class. Something like
public abstract strictfp class MyAbstractClass{} //is ok
If you declare strictfp in a abstract class then all its method is going to be strictfp by default. Remember all the concrete methods in side the class not the abstract methods.
Run the example given below and see the OP:
import java.lang.reflect.*;
public abstract strictfp class AbstractStrictfp
{
public abstract void abstractMethod();
public void concreteMethod(){};
public static void main(String args[]){
Method methods[] = AbstractStrictfp.class.getMethods();
for(Method method : methods){
System.out.println("Method Name::"+method.getName());
System.out.println("Modifiers::"+Modifier.toString(method.getModifiers()));
System.out.println();
}
}
}