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
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Programmer Certification (OCPJP)
Explanation for the statements
Sathya Shanmugam
Ranch Hand
Posts: 45
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi friends
Pls give some detail explanation with example for the following statements from KB book
" A Single object can be referred to by reference variable of many different types - as long as they are the same type or a super type of the object"
Keith Lynn
Ranch Hand
Posts: 2412
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Consider this example.
public class Test { public static void main(String[] args) { D d = new D(); A a = d; B b = d; C c = d; System.out.println(a); System.out.println(b); System.out.println(c); System.out.println(d); } } class A { } class B extends A { } class C extends B { } class D extends C { }
There is only one D object created, but it can be referred to as an A, a B, a C, or a D.
Sathya Shanmugam
Ranch Hand
Posts: 45
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thanks Keith, now I understood the statement clearly with your example.
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Error in Inquisition
Classloader
Integer inheritence problem
Question about Sequence Diagram
Swimming up Stream
More...