Wednesday, 12 September 2012

Java Practical - 2



Program Definition 2 ::
 
Write a class, with main method, which declares floating point variables and observe the output of dividing the floating point values by a 0, also observe the effect of assigning a high integer value (8 digits and above) to a float and casting it back to int and printing.
   

class P2
{
public static void main(String args[])
{

System.out.println(" Program 2 \n\n");

float f1 = 2.2f;
System.out.println(" Float divide by zero :: " + (f1/0));

float f2 = 1234567890f;
System.out.println(" float value = 1234567890 :: " + f2);

int i1 = (int)f2;

System.out.println("int i1 = (int)f2  :: " + i1);


}
}


/*  OUTPUT */

D:\JAVA >java P2
 Program 2

 Float divide by zero :: Infinity
 float value = 1234567890 :: 1.23456794E9
int i1 = (int)f2  :: 1234567936




Kindly Bookmark and Share it:

0 comments :

Post a Comment

Any Query ? any suggestion ? comment here

 

Recent Post

Recent Comments

© 2010 IamLearningHere Template by MBT