This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract classes vs interfaces

 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface methods can be only be public and abstract... and interface variables can be only public, static and final or with no modifier and a value must be assigned to each variable in interface...
Abstract class does not have any restriction in method modifiers, except that abstract and final cannot occur together, abstract and native cannot occur together..Abstract method cannot be static?
Is the above statement correct?
What are the legal modifiers for abstract method?
Thanks.
[ March 27, 2003: Message edited by: sun par ]
[ March 27, 2003: Message edited by: sun par ]
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sun par:
...except that abstract and final cannot occur together, abstract and native cannot occur together..Abstract method cannot be static?
Is the above statement correct?

The following modifiers can not be applied to an abstract method: private, static, final, native, strictfp, or synchronized.
A private method can not be overridden so it makes no sense to declare a method that is both private and abstract.
A static method can be hidden but a static method can not be overridden. It makes no sense to declare a method that is both abstract and can not be overridden.
A final method can not be overridden so it makes no sense to have a final abstract method.
The abstract modifier specifies that a particular method will be implemented by a subclass. The native modifier specifies that the method might not ever be implemented in Java. The two requirements are not compatible so the modifiers are not compatible.
Both strictfp and synchronized specify implementation details that are not enforced on overriding methods. Therefore, it makes no sense to declare a method to be both abstract and strictfp or synchronized.
 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dan
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget to check out the Java Language Specification (8.4.3.1 abstract methods).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic