What is type casting?
Answers were Sorted based on User's Feedback
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 |
Answer / rakesh jain
Whenever u want to assign the value of one type variabel to
another type variable . in this case u must type cast
between them.
Generally there is two type of Type casting
1 Implicit Type Casting
2 Explicit Type Casting
example:=
short s=10;
int i=240;
s=(short)i; //Explicit type casting
Is This Answer Correct ? | 5 Yes | 2 No |
What type of variable is gender?
What is predicate in java?
Does google use java?
What does n mean in java?
What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?
What is Remote Interface ?
How to create an instance of a class if the class has private constructor?
What is the purpose of file class?
What do you understand by copy constructor in java?
Java is pass by value or pass by reference? Explain
how we can create packages in java?
what is the difference between Java Command Line and C command Line?