• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

abstract class

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I need some help for understanding following problem.

abstract class Hall{
public abstract void getFireStation();
}

public class Haddon extends Hall{

public static void main(String argv[]){
new Haddon().getFireStation();
}
public synchronized void getFireStation(){
System.out.print("opposite");
}
}

The output of this is : opposite

My question is that the abstract class Hall has one abstract method. The Haddon class extends abstract class but doesn't seem to define 'same' abstract method getFireStation. It has that method but the signature contains syncronized keyword. Then, isn't it becomes method overloading? And in that case Haddon class also be declared as abstract since the original method from abstract class is not implemented.

How come syncronized method is called?

Thanks in advance.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vivian Josh:
...The Haddon class extends abstract class but doesn't seem to define 'same' abstract method getFireStation. It has that method but the signature contains syncronized keyword...


The method signature is only the name and the argument list. (See Java Tutorial - Methods.) The "synchronized" keyword is not part of the method signature. So this method is, in fact, being overridden and not overloaded.
 
Vivian Josh
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks marc for the explanation.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic