What is type casting?

Answers were Sorted based on User's Feedback



What is type casting?..

Answer / 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

What is type casting?..

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

Post New Answer

More Core Java Interview Questions

Can we sort set in java?

1 Answers  


What is <> used for in java?

1 Answers  


What is the preferred size of a component in java programming?

1 Answers  


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?

1 Answers  


How can we make sure main() is the last thread to finish in java program?

1 Answers  


What does a method signature consist of?

1 Answers  


what ide u r using and wat version, how wil u build the project etc ?

2 Answers  


What exceptions occur during serialization?

1 Answers  


What is method and methodology?

1 Answers  


How do I stop concurrentmodificationexception?

1 Answers  


what do you meant by Runtime Polymorphism?

13 Answers   BVIMR, IBM, Persistent,


what is the form of storage space in java?

5 Answers  


Categories