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 |
can any one tell me what is advantage of encapsulation
Hi Friends, Can u give few interview questions which relates ArrayList and Hashmap. I mean how to link ArrayList and HashMap.I know this is not good way of asking questions like this , but i need
What is race condition ?? (Threading concept) TCS 2 sept10
Can we use string in the switch case?
is there any function in java to make the text to blink?
Differentiate between stringbuffer and string?
What are advantages of using Java?s layout managers than windowing systems?
How do you get the length of a string in java?
Can we define private and protected modifiers for the members in interfaces?
What is cr keyboard?
What is ternary operator? Give an example.
What is meant by tab pans?