what is meant by UP& DOWN casting in java?

Answers were Sorted based on User's Feedback



what is meant by UP& DOWN casting in java?..

Answer / 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

what is meant by UP& DOWN casting in java?..

Answer / paritala.veeraiah chowdary

Casting is the process of converting one data type in to
another.Converting smaller data type into higher data type
is known as up casting.Where as the process of converting
higher data type to lower is known as down casting.

Is This Answer Correct ?    24 Yes 9 No

what is meant by UP& DOWN casting in java?..

Answer / regalla soujanya naresh reddy

A super class reference can be converted into a subclass
reference but this
subclass reference is not useful to call the methods of any
of the classes. This convention is known as Downcasting.

We can convert the subclass reference to a superclass
reference without using the cast operation compiler because
it will internally take care of the casting. This is known
as Upcasting.

Is This Answer Correct ?    9 Yes 0 No

what is meant by UP& DOWN casting in java?..

Answer / keli

UP CASTING: it is the process of assigning subclass reference to the super class.
DOWN CASTING:the process of assigning superclass reference to subclass

Is This Answer Correct ?    6 Yes 4 No

what is meant by UP& DOWN casting in java?..

Answer / javachi

Casting is nothing but data type conversion.
Up casting is the conversion of data type from lower range data type to higher data type eg: int to long, byte to long, int to double etc...
Down casting is vice versa of up casting, here we do type casting from larger value to lower value,
eg: double to byte, long to int etc

Is This Answer Correct ?    2 Yes 4 No

what is meant by UP& DOWN casting in java?..

Answer / jack

i think.. UPcasting is converting one type to another
without any loss of data... and DOWNcasting is converting
one type to another with loss of data

Is This Answer Correct ?    7 Yes 20 No

Post New Answer

More Core Java Interview Questions

Which methods cannot be overridden in java?

0 Answers  


Can a method be static?

0 Answers  


What's the purpose of using break in each case of switch statement?

0 Answers  


What are identifiers in java?

0 Answers  


Hi Friends, I am beginner in java. what i know about synchonized keyword is,If more that one 1 thread tries to access a particular resource we can lock the method using synchronized keyword. Then after that how the lock is released and how next thread access that.Please explain with example.

5 Answers  


What is deserialization and how do we do deserialization?

3 Answers   Synechron,


What is communist flag?

0 Answers  


Why is singleton instance static?

0 Answers  


What is the abstract class?

0 Answers  


Explain implementation and how is it different from conversion?

0 Answers   Aricent,


Are arrays primitive data types?

0 Answers  


What is the difference between int and integer in java?

0 Answers  


Categories