JAVA
Data Types
Fill
in the blanks
1.Write a int
byte value 2
2.Write a
float byte value 4
3.Write a long
int byte value 4
4.Write a double
byte value 8
5.Write a
syntax of type casting (target-type)value
Answer
the Following Questions
(4
marks)
1.Write a
program for type conversion
class ConversionDemo{
public static void main (String args[]){
byte b;
int i= 257;
System.out.println("\nConversion of int to byte.");
b=(byte)i;
System.out.println("i ="+i+" and b="+b);
}
}
2.Write a
program to compute no of seconds in 100 years
class IntegerDemo{
public static void main (String args[]){
int years;
int days;
long nodays;
long seconds;
years = 100;
days = 365;
nodays=years * days;
seconds = nodays*24*60*60;
System.out. println("No of
seconds In"+years);
System.out.println("years is
: "+seconds);
}
}
3.Write a
program to calculate the area of Circle
class DoubleDemo{
public static void main (String args[]){
double a;
float r=10.8f,pi=3.1416f;
a=pi*r*r;
System.out.println("Area of circle is"+a);
}
}
4. Write a
program to calculate the Circumferences of Circle
class DoubleDemo{
public static void main (String args[]){
double a;
float r=10.8f,pi=3.1416f;
a=2*pi*r;
System.out.println("Area of circle is"+a);
}
}
No comments:
Post a Comment