• 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

Dynamic method resolution

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

Advantage of interface is Dynamic method resolution. I saw that one in some books.But I don't know about Dynamic method resolution.
please Any one help me .
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you ihave a variable or argument whose type is an interface, the compiler can be sure the object that the variable refers to at runtime will have the method. But the compiler can't locate the exact code for that method because all it knows for sure is the interface.

Suppose you have a method that takes a List argument and you call a method on the argument. At runtime the JRE has to dynamically call the code defined in the object that's really passed in. It might be the LinkedList code or the ArrayList code. In the early days of OO this dynamic lookup was considered by some to be a fatal flaw - too much overhead and almost guaranteed to cause virtual memory paging. Nowadays it's taken for granted.

More clear or less?
[ May 14, 2005: Message edited by: Stan James ]
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stan James wrote:When you ihave a variable or argument whose type is an interface, the compiler can be sure the object that the variable refers to at runtime will have the method. But the compiler can't locate the exact code for that method because all it knows for sure is the interface.

Suppose you have a method that takes a List argument and you call a method on the argument. At runtime the JRE has to dynamically call the code defined in the object that's really passed in. It might be the LinkedList code or the ArrayList code. In the early days of OO this dynamic lookup was considered by some to be a fatal flaw - too much overhead and almost guaranteed to cause virtual memory paging. Nowadays it's taken for granted.

More clear or less?
[ May 14, 2005: Message edited by: Stan James ]




stan james .. i did read the information you provided for this thread . i can sense some information what you are trying to say . but i can't get enough crystal clear answer sir .. so , if you don't mind show me with a powerful example that which will never ever get out from my mind. please..??
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He wrote that seven years ago, so I think there's a fair chance Stan isn't following this thread any more.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/3359/Ranch-Office/Stan-James-RIP
 
vignesh gopalakrishnan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matthew Brown wrote:He wrote that seven years ago, so I think there's a fair chance Stan isn't following this thread any more.




oh. that's ok . thanks anyways matthew brown .
reply
    Bookmark Topic Watch Topic
  • New Topic