Constructor Program Example
class cube
{
int lenth;
int width;
int height;
cube() //Constructor initilize
{
lenth=10;
width=20;
height=2;
}
int volume()
{
return(lenth*width*height);
}
}
class cons
{
public static void main(String aa[])
{
cube cc1=new cube();
int a=cc1.volume();
System.out.println("the volum of "+a);
}}
class cube
{
int lenth;
int width;
int height;
cube() //Constructor initilize
{
lenth=10;
width=20;
height=2;
}
int volume()
{
return(lenth*width*height);
}
}
class cons
{
public static void main(String aa[])
{
cube cc1=new cube();
int a=cc1.volume();
System.out.println("the volum of "+a);
}}