answersLogoWhite

0


Best Answer

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Explain about type casting in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you change a float into a double using java?

with help of type casting it is possible


Why do use typecasting in java?

Type casting is used to convert from one datatype to the other


Why is there type casting in java?

Type casting exists to allow the use of base class or base interface reference but yet if you know that the object in hand is aspecific derived class, you can typecast and access methods available only in the derived class.


Explain the role of sizeof operator in java?

There is no sizeOf() operator in Java.


Why java is platform independent explain by diagram?

Java is a platform independent language becoz of the bytecode magic of java. In java, when we execute the source code...it generates the .class file comprising the bytecodes. Bytecodes are easily interpreted by JVM which is available with every type of OS we install.


What is a simple java code and explain what the code does?

int a;This simple Java statement declares an integer.


Explain how objects are created in Java?

with new operator


What type of government in java?

Java has a Communist government.


Explain why Java programs running on Android systems do not use the standard Java API and virtual machine?

123


How do you find out if your computer has java?

Open cmd and type java


How do you compile your java code?

save it into a .java file. then open command prompt and navigate to your java bin directory. then type CD then your java bin directory. then type this . javac ProgName.java


How an exception subclass is created in java explain?

We can create a exception sub class by extending Exception class available in java