# Example of Super Class And Calculate Average of Three Variables

by Dinesh Thakur Category: Classes

```class Average

{

int a,b,c;

float av;

Average()

{

a=10;

b=20;

c=30;

}

Average(int x)

{

a=x;

b=40;

c=50;

}

Average(int x, int y)

{

a=x;

b=y;

c=50;

}

Average(int x,int y, int z)

{

a=x;

b=y;

c=z;

}

void getAverage()

{

av=(float)(a+b+c)/3;

System.out.println("Average of three variables is "+av);

}

}

class disc extends Average

{

int d;

disc()

{

super();

}

disc(int x)

{

super(x);

}

disc(int x, int y)

{

super(x,y);

}

disc(int x, int y, int z)

{

super(x,y,z);

}

void getdic()

{

d=b*b-4*a;

}

}

class Averagesuper

{

public static void main(String args[])

{

Average p=new Average();

Average q=new Average(15);

Average r=new Average(15,30);

Average s=new Average(15,30,45);

disc t=new disc();

disc u=new disc(15);

disc v=new disc(15,30);

disc w=new disc(15,30,45);

p.getAverage();

q.getAverage();

r.getAverage();

s.getAverage();

t.getdic();

u.getdic();

v.getdic();

w.getdic();

}

}

```  Dinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles