class square
{
int l;
square()
{
System.out.println("i am in square()");
l=10;
System.out.println("i am in square() and l :"+l);
}
square(int x)
{
System.out.println("i am in square(x) and l :"+l);
}
void area()
{
System.out.println("i am in area()");
System.out.println("area of square :"+l*l);
}
public static void main(String args[])
{
square square1=new square();
square1.area();
square square2=new square(20);
square2.area();
}
}
==================================================
output :
i am in square()
i am in square() and l :10
i am in area()
area of square :100
i am in square(x) and l :0
i am in area()
area of square :0
{
int l;
square()
{
System.out.println("i am in square()");
l=10;
System.out.println("i am in square() and l :"+l);
}
square(int x)
{
System.out.println("i am in square(x) and l :"+l);
}
void area()
{
System.out.println("i am in area()");
System.out.println("area of square :"+l*l);
}
public static void main(String args[])
{
square square1=new square();
square1.area();
square square2=new square(20);
square2.area();
}
}
==================================================
output :
i am in square()
i am in square() and l :10
i am in area()
area of square :100
i am in square(x) and l :0
i am in area()
area of square :0