Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Implementing abstract methods in the concrete subclass  RSS feed

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
While implementing abstract methods in the first concrete subclass, should the overriding priciples be used?.
For example, I found the following code working though I was under the understanding that the signature of the implementing method in the subclass should be the same as that of the Abstract class.
The method has been marked synchronized in the subclass.
Can someone explain this ?
abstract class mytest70{
public abstract void getFireStation();
}
public class mytest71 extends mytest70{
public synchronized void getFireStation()
{
System.out.println("Fire....");
}
public static void main(String[] args){
mytest71 m = new mytest71();
m.getFireStation();
}
}
Thanks!!
 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepa,
See my in-line comments..
While implementing abstract methods in the first concrete subclass, should the overriding priciples be used?.
>> Yes you should follow overriding priciples.
For example, I found the following code working though I was under the understanding that the signature of the implementing method in the subclass should be the same as that of the Abstract class.
The method has been marked synchronized in the subclass.
>> Declaring the method as synchronized or not will not come under method signature. Hence the overriding method can be declared as synchronized. It is at the discretion of the sub class to declare its methods are synchronized or not.
Hope this helps, if not come with more doubts..
 
Deepa Guha
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
This means that non-access modifiers can be added to the subclass method signature.These would include strictfp,synchronized,static,final etc..
This is correct?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!