Experiment-1
Title: Write a demo program to display Hello World
Code:
class Demo1
{
public static void main(String args[])
{
System.out.println("Hello World");
}
}
Output:
, Experiment-2
Title: Write a demo program on Datatypes
Code:
class PrimitiveDemo
{
public static void main(String args[])
{
byte b= 100;
short s = 123;
int v = 123543;
int calc = -9876345;
long amountVal = 1234567891;
float interestRate = 12.25f;
double sineVal = 12345.234d;
boolean flag = true;
boolean val = false;
char ch1 = 88;
char ch2 = 'y';
System.out.println("byte Value = "+b);
System.out.println("short Value = "+s);
System.out.println("int Value = "+v);
System.out.println("int second Value="+calc);
System.out.println("long Value = "+amountVal);
System.out.println("float Value = "+interestRate);
System.out.println("double Value = "+sineVal);
System.out.println("boolean Value="+flag);
,System.out.println("byte Value = "+val);
System.out.println("char Value = "+ch1); System.out.println("char Value =
"+ch2);
}
}
Output:
, Experiment-3
Title: Write a demo program on type conversion
Code:
class Demo
{
public static void main(String args[])
{
char ch1 ='A';
double d1 =ch1;
System.out.println(d1);
System.out.println(ch1*ch1);
double d2 =66.0;
char Ch2 =(char)d2;
System.out.println(Ch2);
}
}
Output:
Title: Write a demo program to display Hello World
Code:
class Demo1
{
public static void main(String args[])
{
System.out.println("Hello World");
}
}
Output:
, Experiment-2
Title: Write a demo program on Datatypes
Code:
class PrimitiveDemo
{
public static void main(String args[])
{
byte b= 100;
short s = 123;
int v = 123543;
int calc = -9876345;
long amountVal = 1234567891;
float interestRate = 12.25f;
double sineVal = 12345.234d;
boolean flag = true;
boolean val = false;
char ch1 = 88;
char ch2 = 'y';
System.out.println("byte Value = "+b);
System.out.println("short Value = "+s);
System.out.println("int Value = "+v);
System.out.println("int second Value="+calc);
System.out.println("long Value = "+amountVal);
System.out.println("float Value = "+interestRate);
System.out.println("double Value = "+sineVal);
System.out.println("boolean Value="+flag);
,System.out.println("byte Value = "+val);
System.out.println("char Value = "+ch1); System.out.println("char Value =
"+ch2);
}
}
Output:
, Experiment-3
Title: Write a demo program on type conversion
Code:
class Demo
{
public static void main(String args[])
{
char ch1 ='A';
double d1 =ch1;
System.out.println(d1);
System.out.println(ch1*ch1);
double d2 =66.0;
char Ch2 =(char)d2;
System.out.println(Ch2);
}
}
Output: