• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

strictfp and abstract

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A class be marked both strictfp and abstract.
A method cannot be marked both strictfp and abstract.

please tell me the reason behind this.
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Strictfp indicates that intermediate floating point calculations are not to be rounded so that decimal precision is not lost on the final calculation. In the case of a method which is abstract, it does not make sense to tell the compiler to use strictfp when there is no code to do the calculations with. Hence, it is not allowed. In the case of an abstract class, not all methods need to be abstract for the class to be abstract. Thus, you could potentially have some methods which are fully defined and you want the calculations to be precise.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have heard that abstract methods can not be marked strictfp
however I tried it and I was able to compile just fine.
Any ideas? I compiled the following code with 1.4:

public abstract class test {
public strictfp abstract void doSomething ();
}

Thanks,
Angela
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The good news is that the strictfp modifier does not appear on the exam. My mock exams once contained questions about the strictfp modifier, but I removed those questions to save Kathy and Bert the trouble of telling my mock exam users not to worry about it.

Some platforms are able to do floating point calculations with a level of precision that exceeds that which is required by the Java Language Specification and by the IEEE 754 standard. Precision that exceeds the Java Language Specification can be good, but it can also contradict the "write once, run anywhere" philosophy. In situations where you want to make sure that a floating point calculation produces the same result on any platform, you can use the strictfp modifier.

The strictfp modifier specifies an implementation detail that an overriding method is not required to support. For that reason, an application of the strictfp modifier to an abstract method declaration has no impact on the implementation of the overriding method in the subclass. Since the strictfp modifier is useless when applied to an abstract method, the Java Language Specification requires the compiler to throw a compile-time exception to let the programmer know that the modifier has no impact.
 
Angela Gordon
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Dan and also thank you for your mock exam site.
I have went through all of your Study Guide 2 questions
and they were very helpful!! Thanks again - Angela
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for using my exams, Angela!
 
Maybe he went home and went to bed. And took this tiny ad with him:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic