What do you understand by casting in Java What are types of casting

What do you understand by casting in Java What are types of casting

Answer : Assign a value of one type to a variable of another type known as casting. Type conversion, typecasting, and coercion are different ways of, implicitly or explicitly, changing an entity of one data type into another.

There two types of casting available:

Implicit casting: Implicit or automatic type conversion occurs if below conditions are met:

  • The two types are compatible.
  • The destination type is larger than the source type.

For detail answer check this

Explicit casting: For detail answer please check this

Leave a Reply

Your email address will not be published. Required fields are marked *