
1.Create an interface names ShapeInterface that has two methods and one constant and an abstract class named ShapeAbstract that has two instance variable, one abstract and one non-abstract method. Create a concrete class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class

interface ShapeInterface{
int l=0,b=0;
public void area();
public void perimeter();
}
abstract class ShapeAbstract {
double PI=3.14,r=0;
public void areaOfCircle() {
}
abstract public void circumference();
}
class Rectangle implements ShapeInterface{
int l=10,b=5;
public void area(){
int ar=l*b;
System.out.println("Area of Rectangle: "+ar);
}
public void perimeter(){
int k=l+b;
int p=2*k;
System.out.println("Perimeter of Rectangle: "+p);
}
}
class Circle extends ShapeAbstract implements ShapeInterface {
int r=5;
int l=15,b=10;
public void areaOfCircle() {
double area=PI*r*r;
System.out.println("Area of Circle: "+area);
}
public void circumference(){
double cir=2*PI*r;
System.out.println("Circumference of Circle: "+cir);
}
public void area(){
int ar=l*b;
System.out.println("Area of Rectangle: "+ar);
}
public void perimeter(){
int k=l+b;
int p=2*k;
System.out.println("Perimeter of Rectangle: "+p);
}
}
class InterfaceAndAbstractClass{
public static void main(String[]args){
Rectangle a=new Rectangle();
a.area();
a.perimeter();
System.out.println();
Circle b=new Circle();
b.areaOfCircle();
b.circumference();
b.area();
b.perimeter();
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.