Aoop Lab
Aoop Lab
Main class
package shape;
/**
* @author student
*/
shape.show();
circle.show();
rectangle.show();
System.out.println("inherited method");
shape.getInfo();
circle.getInfo();
rectangle.getInfo();
}
package shape;
/**
* @author student
*/
System.out.println("Circle");
package shape;
/**
*
* @author student
*/
System.out.println("Rectangle");
package shape;
/**
* @author student
*/
System.out.println("Shape");
{
System.out.println("This is Shape class");
Output:
Question number 2:
package shape;
/**
* @author student
*/
}
}
package shape;
/**
* @author student
*/
System.out.println("Circle");
package shape;
/**
* @author student
*/
System.out.println("Rectangle");
circle.show();
rectangle.show();
System.out.println("inherited method");
circle.getInfo();
rectangle.getInfo();
}
}
Output:
Question number 6
package shape;
/**
* @author intag
*/
int x, y;
Shape(int x, int y) {
this.x = x;
this.y = y;
super(length, width);
void printArea() {
super(base, height);
void printArea() {
}
class circle extends Shape {
super(radius, 0);
@Override
void printArea() {
} package shape;
rectangle.printArea();
triangle.printArea();
circle.printArea();
}
Question number 7
interface Drawable {
void draw();
// Interface Measurable
interface Measurable {
double getArea();
double getPerimeter();
Circle(double radius) {
this.radius = radius;
}
// Class Rectangle implementing Drawable and Measurable
this.length = length;
this.width = width;
System.out.println("Drawing a rectangle with length " + length + " and width " + width);