0% found this document useful (0 votes)
6 views

Inhertice Java ChiranjeebLAB

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Inhertice Java ChiranjeebLAB

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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) {
this.radius = radius;
}
@Override
double area() {
return Math.PI * radius * radius;
}
}
class Rectangle extends Shape {
private double length;
private double width;
Rectangle(double length, double width) {
this.length = length;
this.width = 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
System.out.println("Area of Circle: " + circle.area());
System.out.println("Area of Rectangle: " + rectangle.area());
}
}

* 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.

You might also like