Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Programmer Certification (OCPJP)
polymorphic reference variables
adam Lui
Ranch Hand
Posts: 186
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
by declaring a reference variable of the superclass type and have that reference variable refer to an instance of a subclass type, WHATs the benefit? can anyone show an example?
Ameen khan
Ranch Hand
Posts: 52
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
the benefit is dynamic method Dispatch, versioning, latebinding
class A{ void method1(){ System.Out.print("methodA"); }} public class B extends A{ void method1(){ System.Out.print("methodB"); } public static void main(String[] args){ A a = new B(); a.method1(); //answer will be methodB } }
[ September 29, 2007: Message edited by: Ameen khan ]
SCJP 5.0<br />Next-> I Don't Know
ahmed yehia
Ranch Hand
Posts: 424
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
See this
post
for a longer dicussion.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Overriding,Overloading - Question
Confusion about array instance
instanceof operator
Problem using pollLastEntry() method from TreeMap
explanation of Interface concept
More...