School: ............................................................................................................. Campus: .......................................................
Academic Year: ...................... Subject Name: ........................................................... Subject Code: ..........................
Semester: ............... Program: ........................................ Branch: ......................... Specialization: ..........................
Date: .....................................
(Learning by Doing and Discovery)
* Coding Phase: Pseudo Code / Flow Chart / Algorithm
1. Create a base class Shape with two subclasses Circle and Rectangle. Each
subclass should have a method area that calculates the area of the shape.
The Circle class should have a constructor that takes the radius as a
parameter, and the Rectangle class should have a constructor that takes
the length and width as parameters. Implement the classes and write a
program to demonstrate their use by creating instances of each shape and
printing their areas.
* As applicable according to the experiment.
Two sheets per experiment (10-20) to be used.
Applied and Action Learning
* Testing Phase: Compilation of Code (error detection)
* As applicable according to the experiment.
Two sheets per experiment (10-20) to be used.
Applied and Action Learning
* Implementation Phase: Final Output (no error)
class Shape {
// Empty constructor
Shape() {
}
double area() {
return 0.0;
}
}
class Circle extends Shape {
private double radius;
Circle(double radius) {
[Link] = radius;
}
@Override
double area() {
return [Link] * radius * radius;
}
}
class Rectangle extends Shape {
private double length;
private double width;
Rectangle(double length, double width) {
[Link] = length;
[Link] = width;
}
@Override
double area() {
return length * width;
}
}
public class Main {
public static void main(String[] args) {
// Create instances of Circle and Rectangle
Circle circle = new Circle(5);
Rectangle rectangle = new Rectangle(4, 6);
// Print areas
[Link]("Area of Circle: " + [Link]());
[Link]("Area of Rectangle: " + [Link]());
}
}
* As applicable according to the experiment.
Two sheets per experiment (10-20) to be used.
Applied and Action Learning
Rubrics
Concept 10
Planning and Execution/ 10
Practical Simulation/ Programming
Result and Interpretation 10
Record of Applied and Action Learning 10
Viva 10
Total 50
Signature of the Student:
Signature of the Faculty:
* As applicable according to the experiment.
Two sheets per experiment (10-20) to be used.