Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question about abstract and strictfp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question about abstract and strictfp" Watch "Question about abstract and strictfp" New topic
Author

Question about abstract and strictfp

Brian Nguyen
Greenhorn

Joined: Mar 19, 2002
Posts: 22
Hi,
This is something that I read from one of Study book:
Class Modifiers:
- You are free to use strictfp in combination with abstract or final...
Abstract Methods:
- Abstract methods cannot be marked as synchronized, strictfp or native...

So my question here is that why we can have a combination of abstract class and strictfp but not the combination of abstract method and strictfp?

Thanks for your answer in advance.
Brian
Bruce Evans
Greenhorn

Joined: Nov 28, 2004
Posts: 14
Sorry for the earlier non-reply (hit submit accidentally)

native, synchronized and strictfp describe part of the
implementation of the method.

An abstract method can't say anything about its implementation.

HTH

-Bruce

Originally posted by Brian Nguyen:
Hi,
This is something that I read from one of Study book:
Class Modifiers:
- You are free to use strictfp in combination with abstract or final...
Abstract Methods:
- Abstract methods cannot be marked as synchronized, strictfp or native...

So my question here is that why we can have a combination of abstract class and strictfp but not the combination of abstract method and strictfp?

Thanks for your answer in advance.
Brian
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Bruce Evans:
An abstract method can't say anything about its implementation.


That's true, Bruce, but, at the same time, I got this from the JLS:


The effect of the strictfp modifier is to make all float or double expressions within the class declaration be explicitly FP-strict (�15.4). This implies that all methods declared in the class, and all nested types declared in the class, are implicitly strictfp.


If that's the case, it would seem odd that you can declare a class to be strictfp (and therefore make all of its methods strictfp) but you can still declare one or more of those methods to be abstract. In essence, you've created an abstract, strictfp method. Doing so explicitly, however, produces a compiler error.

I must say that I never use the strictfp modifier so I'm not well versed in its usage, but there does seem to be, in my opinion, anyway, some degree of contradiction here.


SCJP Tipline, etc.
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Corey Said:
it would seem odd that you can declare a class to be strictfp (and therefore make all of its methods strictfp) but you can still declare one or more of those methods to be abstract. In essence, you've created an abstract, strictfp method. Doing so explicitly, however, produces a compiler error.


A class strictfp modifier does not affect abstract method declarations in that class. Also, a class strictfp modifier is not inherited by subclass declarations, so it won't affect abstract methods when they are implemented in subclasses.

The following compiles OK:


Mike Gershman
SCJP 1.4, SCWCD in process
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about abstract and strictfp