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

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.
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic