• 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
  • Tim Cooke
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst
  • Peter Rooke
  • Mikalai Zaikin
Bartenders:
  • Himai Minh

Implementing abstract methods in the concrete subclass

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic