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 is the diff. b/w Interfaces & Abstract class?
What is stream api in java8?
What is hashing in java?
Explain features of interfaces in java?
How to know the host from which Applet is originated?
Can we overload the methods by making them static?
Why is java called the platform independent programming language?
Can inner class final?
Explain difference between final, finally and finalize?
What happens when a main method is declared as private?
22 Answers DELL, Infosys, L&T, Sun Microsystems,
Define an abstract class with reference to java.
Why is java not 100% pure oops?