Answer Posted / sabeetha
Down Casting is nothing but casting down the inheritance
tree to a more specific class i.e casting a superclass to
subclass.
Upcasting- casting up the inheritance tree to a more general
type. It is done implicitly (i.e typing in the cast is not
required). Its because the classes at lower level of
hierarchy have all those features that are present in the
classes above them in the inheritance hierarchy. So they can
be upcasted implicitly ( like Dog IS-A Animal).
I got this answer
from(http://javaforyou.wordpress.com/2008/06/22/casting-reference-variables-downcasting-upcasting/)
with example.
| Is This Answer Correct ? | 19 Yes | 2 No |
Post New Answer View All Answers
Explain about procedural programming language or structured programming language and its features?
What are the two main uses of volatile in Java?
Can bool be null?
Explain when we should make an instance variable private.
What are voids?
Can we pass a primitive type by reference in java? How
Why are getters and setters used?
What is lambda expression in java?
Can an interface have a constructor?
How does a for loop work java?
What does @override mean?
Is it possible to specify multiple jndi names when deploying an ejb?
What is local variable and instance variable?
How many bytes is a string?
What is an immutable object?