Java Constructor program
class rectangle
{
double length,height;
rectangle()
{
length=10;
height=10;
}
double volume()
{
double volume=length*height;
System.out.println("Volume is"+volume);
return volume;
}
}
class constructor
{
public static void main(String args[])
{
rectangle rec=new rectangle();
rec.volume();
}
}
{
double length,height;
rectangle()
{
length=10;
height=10;
}
double volume()
{
double volume=length*height;
System.out.println("Volume is"+volume);
return volume;
}
}
class constructor
{
public static void main(String args[])
{
rectangle rec=new rectangle();
rec.volume();
}
}
No comments:
Post a Comment