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 exactly is methodology?

468


What is jvm? Why is java called the platform independent programming language?

531


What is the difference between choice and list?

581


What is a condition in java?

522


When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?

595






Which is faster set or list in java?

514


What does java stand for?

534


Explain about java sdk?

570


What is the order of arraylist in java?

594


Explain differences between collection api and stream api?

600


What is the effect of keeping a constructor private?

464


How do you reverse sort in java?

487


Can we declare the main method of our class as private?

542


What is the java project architecture?

1771


What is the purpose of extern variable?

522