Set 9
Set 9
}
Cube(double l,double b, double h){
length = l;
bredth = b;
height = h;
}
Cube(Cube c2){
length = c2.length;
bredth = c2.bredth;
height = c2.height;
}
void volume(){
System.out.println("Volume of Cube : "+ (length * bredth * height));
}
public static void main(String[] args){
Cube c1 = new Cube();
Cube c2 = new Cube(9,9,9);
Cube c3 = new Cube(c2);
c1.volume();
c2.volume();
c3.volume();
}
}
2)
a.start();
m.start();
}
}
3)
class Circle
{
double radius;
double pi=3.14;
Circle(double r)
{
radius=r;
}
void display()
{
System.out.println("Radius : "+radius);
System.out.println("PI : "+pi);
}
void area()
{
System.out.println("Area : "+(pi*radius*radius));
}
}
class P9_3
{
public static void main(String args[])
{
Circle c=new Circle(7);
c.display();
c.area();
}
}
4)
import java.applet.Applet;
import java.awt.*;
g.drawPolygon(xPoints,yPoints,n1);
}
}
/*
<applet code="P9_4" width=500 height=500>
</applet>
*/
5)
import java.io.FileReader;
public class P9_5
{
public static void main(String args[]) throws IOException
{
FileReader fin=new FileReader(args[0]);
int i;
while((i=fin.read())!= -1)
{
System.out.print((char)i);
}
fin.close();
}
}