Arti Languages Pre Seed Send Ahead Pitchdeck 2024.pdf
Conversion of data types in java
1. //Ques. 7 WAP to demonstrate type conversions ( int to byte, double to int,
double to byte ).
class conversion
{
public static void main(String arr[])
{
byte b;
inti = 257;
double d = 323.142;
System.out.println(" n Conversion of int to byte: ");
b= (byte) i;
System.out.print(" i = "+i+ " b = "+b);
System.out.println("n n Conversion of double to int: ");
i= (int) d;
System.out.print(" d = "+d+ " i = "+i);
System.out.println("n n Conversion of double to byte: ");
b= (byte) d;
System.out.println(" d = "+d+ " b = "+b);
}
}