• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

abstract/concrete methods and modifiers

 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that certain modifiers can not be applied to abstract methods such as synchronized or native.
What about the concrete methods that imjplement the abstract methods? Can these use the modifiers?
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the JLS, §8.4.3 Method Modifiers. It has all of the information you want and then some.
 
Damien Howard
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems then that a concrete implementation of an abstract method could never be synchronized or written in a native language then.
Is that correct?
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Damien Howard:
It seems then that a concrete implementation of an abstract method could never be synchronized or written in a native language then.
Is that correct?


Where did you find that in the JLS? An abstract method can't be native but the implementation of an abstract method can be.
 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Damien Howard:
I know that certain modifiers can not be applied to abstract methods such as synchronized or native.
What about the concrete methods that imjplement the abstract methods? Can these use the modifiers?


I think any modifier can be applied to concrete method as it is not abstract anymore.Correct me if I am wrong.
Veena
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you mean this,
abstract class A
{
abstract void aMethod();
}
class B extends A
{
synchronized void aMethod(){ }
//native void aMethod();
public static void main(String[] arg)
{
}
}

then this code compiles without any issues.
reply
    Bookmark Topic Watch Topic
  • New Topic