What is casting?

Answer Posted / vijayakumar chinnasamy

Casting mostly used for converting value from one data type
to another data type.Mostly used for convert incompatible
data.

eg:

WRRONG
long a=20; // a is 64bit(long) data
int b=10; // b is 32 bit data.
b=a; // u r trying to assign 64bit data into 32 bit data

CORRECT
long a=20; // a is 64bit(long) data
int b=10; // b is 32 bit data.
b=(int)a; // ur converting 64bit data into 32bit data
then assign to variable b.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between final, finally and finalize()?

651


How dead lock situation occurs in java and how you can identify it?

633


How do you trim a space in java?

598


Say any two properties in beans?

714


What is sortedmap interface?

647






What is difference between arraylist and list in java?

660


What is an off by one error in java?

586


Why string is immutable with example?

624


What is the purpose of static keyword in java?

602


What is the difference between a vector & an array list?

777


Is set ordered?

632


What are the steps involved to create a bean?

761


What is the main use of generics in java?

604


What is java used for?

650


What is an array in java?

735