wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method : abstract - native - synchronized - strictfp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method : abstract - native - synchronized - strictfp" Watch "method : abstract - native - synchronized - strictfp" New topic
Author

method : abstract - native - synchronized - strictfp

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
It is mention on page 88 of K&B that :

abstract method can't be marked as synchronized , strictfp or native . all of this modifier describing something about the implementation of a method & abstract method doesn't say anything about implementation .

My doubts are :

1] strictfp describe something about implementation & abstract not ... then how is permitted in case of class .

strictfp abstract class A {}

2] How synchronized keywork describing anthing about implementation . It is just like that if one thread is using then other can't use .



please help me ...
thanks a lot ...
[ January 13, 2005: Message edited by: rathi ji ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

For doubt #1, see...

http://www.coderanch.com/t/398241/java/java/interface-abstract-or-strictfp

For doubt #2, note that the synchronized keyword is not passed via inheritance. Since abstract methods defer implementation to a subclass, it would do no good to mark them as synchronized.

Ref: http://www.janeg.ca/scjp/threads/synchronization.html
[ January 13, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Actually, none of these modifiers are retained when a method is overridden (i.e., when an abstract method is implemented), so it would do no good to use any of these modifiers along with abstract.

This can be verified using reflection...


NOTE: The output of this code makes me question the oft-quoted statement, "the synchronized modifier is not passed via inheritance." I think it's probably more accurate to say, "the synchronized modifier is not retained when a method is overridden." Comments?
[ January 13, 2005: Message edited by: marc weber ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method : abstract - native - synchronized - strictfp
 
Similar Threads
Non access modifier strictfp and intefaces
can i use the non-access modifier strictfp with abstract for a method declaration
Question about abstract and strictfp
modifers
abstract strictfp class legal?