source file name: Lines.java

class Line

{

int a,b,c;

public Line(int p,int q,int r)

      {

       a=p;b=q;c=r;

      }

public void slope()

{

int m=a;

System.out.println("slope is:"+m);

}

public void yintercept()

{

int yi;

yi=a-c/b;

System.out.println(" y intercept is: "+yi);

}

public void xintercept()

       {

int xi;

xi=b-c/a;

System.out.println(" x intercept is:"+xi);

        }

}

class Lines

{

public static void main(String as[])

{

Line l1=new Line(1,2,3);

l1.slope();

l1.yintercept();

l1.xintercept();


Line l2=new Line(5,2,6);

l2.slope();

l2.yintercept();

l2.xintercept();

}

}

output:

D:\JavaPrograms\Constructors>javac Lines.java

D:\JavaPrograms\Constructors>java Lines
slope is:1
 y intercept is: 0
 x intercept is:-1
slope is:5
 y intercept is: 2
 x intercept is:1