• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Strange o/p.Polymorphism in Overrided method?

 
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


For the above pgm, how the o/p is: AAA

In all the three classes m1 has been overrided and polymorphism will come to play. so the below line
A3 a4 = new C3();
ref var is A3 and resolved at compile time, but while run time it has to call the C3 object's m1() only.. how it's calling A3 object's m1()?
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice there is no overriding because the methods do not have the same signatures.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not overriding you are overloading the methods. And which methods to be called will be determined by the referenced type
    Bookmark Topic Watch Topic
  • New Topic