Type Casting and Conversion
Assigning a value of one type to a variable of another type is known as Type Casting. In Java, type casting is classified into two types,
Widening or Automatic type conversion: Automatic Type casting take place when, the two types are compatible and the target type is larger than the source type.
Narrowing or Explicit type conversion:When you are assigning a larger type value to a variable of smaller type, then you need to perform explicit type casting.
Working Flow chart
Different Cases of Explicitly and Implicit
Case 1:
All Statement is true.
Case 2:
Thread Line is not compile, Error is possible loss of precision.
Case 3:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 4:
All Statement is true.
Case 5:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 6:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 7:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 8:
Thread Line is not compile, Error is possible loss of precision
Forth Line is compile and run
Case 9:
Thread Line is not compile, Error is possible loss of precision
Forth Line is compile and run
Case 10:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 11:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 12:
All Statement is true.
Case 13:
All Statement is true.
Case 14:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
etc......
Widening or Automatic type conversion: Automatic Type casting take place when, the two types are compatible and the target type is larger than the source type.
Narrowing or Explicit type conversion:When you are assigning a larger type value to a variable of smaller type, then you need to perform explicit type casting.
Working Flow chart
Different Cases of Explicitly and Implicit
Case 1:
All Statement is true.
Case 2:
Thread Line is not compile, Error is possible loss of precision.
Case 3:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 4:
All Statement is true.
Case 5:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 6:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 7:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 8:
Thread Line is not compile, Error is possible loss of precision
Forth Line is compile and run
Case 9:
Thread Line is not compile, Error is possible loss of precision
Forth Line is compile and run
Case 10:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 11:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
Case 12:
All Statement is true.
Case 13:
All Statement is true.
Case 14:
Thread Line is not compile, Error is possible loss of precision.
Forth Line is compile and run.
etc......