• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

overloaded-overriden

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

O/P : ABC

Class B extends class A and Class C extends class B, therefore method m1() is overdidden right?.
But according to the output, method m1() is overloaded. Some one please explain how method m1() is overloaded and not overridden.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Here the method m1() in subclasses B and C overloads the method m1() inherited from its parent class A.

Overridding methods should have same method signature, both method parameters and return type should be same.

Thanks,
Raja
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
method parameters are different.so it is method overloading.Overridden method signature must be same.

Note:
In Java 1.5 the return type of the overriding method can be different.
When you override a method, the declared return type can be any subclass of the the class returned by the original method. Currently, the method signature of an overriding method has to match exactly that of the method that it is overriding, including the return type.

http://forum.java.sun.com/thread.jspa?threadID=477074&messageID=2215964
 
reply
    Bookmark Topic Watch Topic
  • New Topic