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
What is arrays fill in java?
What is serial version uid and its importance in java?
Explain the hierarchy of java exception classes?
Why set is used in java?
What is the difference between length and length() method in java?
Is empty string in java?
Can a set contain duplicates?
What do you mean by constructor?
what is difference between equals and ==?
explain different ways of using thread? : Java thread
How to perform selection sort in java?
what is use of functional interface in java 8?
When throw keyword is used?
What is the synonym of procedure?
What are the different ways of implementing thread? Which one is more advantageous?