• 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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.
 
I was her plaything! And so was this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic