Computer Science, asked by opo, 1 year ago

example of a explicit conversion type in java

Answers

Answered by kanika58
5
Type conversion in Java with Examples


When you assign value of one data type to another, the two types might not be compatible with each other. If the data types are compatible, then Java will perform the conversion automatically known as Automatic Type Conversion and if not then they need to be casted or converted explicitly. For example, assigning an int value to a long variable.

Widening or Automatic Type Conversion

Widening conversion takes place when two data types are automatically converted. This happens when:

The two data types are compatible.

When we assign value of a smaller data type to a bigger data type.

For Example, in java the numeric data types are compatible with each other but no automatic conversion is supported from numeric type to char or boolean. Also, char and boolean are not compatible with each other

mark it as a brainliest answer
follow me also


kanika58: dis is vomit
opo: idiot muh se Nahi haat se type Kar raho hu
kanika58: on your face
opo: ladke ho ke ladki jaisi bate Kar rahe ho
opo: abhi Hindi Nahi aa rahi thi
opo: tum zaroor pagal ho
opo: side ham naa key DE tumhare Chere par sabji Mandi lagi hui hai
opo: agli bar aa na jana
opo: lo thanks
opo: bhik DE diya
Answered by siddhartharao77
2
Explicit type conversion in Java:

It is performed explicitly That means if you are performing the typecasting then it is called as Explicit conversion.


Here is the example without Typecasting:

public static void main(String[] args)
{

int i = 100;
byte b;
b = i;
System.out.println("Demo");
}

Output: Compilation Error.

Because: Datatype mismatch


Now,

Here is the example of Explicit typecasting:

public static void main(String[] args)
{

int i = 100;
byte b;
b=(byte)i;
System.out.println(("Demo");
}



Hope this helps!

siddhartharao77: If possible brainliest it
Similar questions