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

Why string is popular hashmap key in java?

1 Answers  


How many bits does a boolean take?

1 Answers  


When do we need to use internal iteration? When do we need to use external iteration?

0 Answers  


Is null a value?

0 Answers  


What is Hierarchy of exception?

0 Answers   Amdocs,






Where are global variables stored?

0 Answers  


Accenture NJ mostly ask question on Collection like 1)How to sort Objcts and how treeset sort them 2)Explain mechanism of Hashcode finding in Java 3)Name some of the Sorted collection.

2 Answers   Accenture,


What is the output of the below java program?

0 Answers  


Can we assign null to double in java?

0 Answers  


What are the drawbacks for singleton class?

0 Answers  


What is module in oop?

0 Answers  


What are 5 boolean operators?

0 Answers  


Categories