using modifiers for abstarct method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    using modifiers for abstarct method

    why can't we use final, static, native, synchronized, private modifiers in abstract method ...

    explain me in details ...

    thanx in advance
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by dmjpro
    why can't we use final, static, native, synchronized, private modifiers in abstract method ...

    explain me in details ...

    thanx in advance

    The idea behind an abstract method is that even though you know that all objects of a general type have a certain method, the implementation of that method is different for more specialized types of that general type. So you define the method and leave it's body blank. Inheriting classes can then implement this method.


    The reason why the static modifier is not allowed already been discussed here.

    final means that the method cannot be overriden in subclasses so again it would not be possible to write that method's body. final is essentially the opposite of abstract.

    native methods are not written in the Java language and so you cannot have a subclass that is going to implement that method because native classes cannot extend Java classes

    To synchronize an abstract method does not make sense. There is no code for the method so there is no critical section to block threads from entering.

    private methods are not accessible in subclasses. They are visible only within the class that they have been defined. This means that inheriting classes cannot override private methods of their superclasses because they cannot see them. So such a declaration cannot be allowed.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      thanx a lot ..

      fantastic answer ........

      Comment

      Working...