Conversion of data types in java

344 views
258 views

Published on

WAP to demonstrate type conversions ( int to byte, double to int, double to byte ).

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
344
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Conversion of data types in java

  1. 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); } }
  2. 2. OUTPUT:-

×