What is type casting?

Answer Posted / sitaram

casting means one type of date to another type of data.
There are two types
1.Implicit Type Casting.
2.Explicit Type Casting.

public class One {
static short i=10;
int k =i; //implicit
byte b = (byte)i;//Explicit
public static void main(String[] args) {
System.out.println("integer i..."+i);
}
}

1.Implicit Casting :
===================
The small data type will be automatically covert to big data
type.
Example:
static short i=10;
int k =i; //implicit
2.Explicit Casting:
===================
The big data type will be convert to small data type by type
casting.
Example:
static short i=10;
byte b = (byte)i;//Explicit

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a field variable and a local variable?

569


Difference between java and javascript

581


What is empty string literal in java?

558


What is the benefit of inner classes in java?

603


Can finally block be used without a catch?

540






What is exception in java?

563


What do you mean by garbage collection used in java?

568


What are nested classes in java?

600


What is hash in java?

512


What is the gregoriancalendar class in java programming?

566


How do you override a variable in java?

525


How many bytes is a url?

558


Can we have this () and super () together?

602


What is sortedmap in java?

547


What are the benefits of operations?

509