You are on page 1of 4

Expreiment :7

Student Name:Raghav kumar duggal UID:19bca1469


Branch: BCA Section/GroupB/2
Semester:4th Date of Performance: 12/04/21
Subject Name: INTERNET PROGRAMMING LAB Subject Code: CAP-256

• Aim/Overview of the practical:


• We have to calculate the area of a rectangle, a square and a circle. Create an interface
'Shape' with three abstract methods namely 'RectangleArea' taking two parameters,
'SquareArea' and 'CircleArea' taking one parameter each. The parameters of
'RectangleArea' are its length and breadth, that of 'SquareArea' is its side and that of
'CircleArea' is its radius. Now create another class 'Area' containing all the three
methods 'RectangleArea', 'SquareArea' and 'CircleArea' for printing the area of
rectangle, square and circle respectively. Create an object of class 'Area' and call all the
three methods.

• 4.package
com.company;
import
java.util.Scan
ner;


• interface shape
• {
• public void rectangle(int
length,int breadth); public void
square(int side);
• public void circle(int radius);
• }
• class area implements shape {

• @Override
• public void rectangle(int length,
int breadth) { int
area=length*breadth;
System.out.println(area);
• }

• public void
square(int side){
int
area=side*side;
System.out.println
(area);
• }

• public void
circle(int
radius){ double
pi=3.14;
• double
area=pi*radius*rad
ius;
System.out.println
(area);
• Code for experiment/practical:

5. Result/Output/Writing Summary:
"C:\Program Files\Java\jdk-16\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ
IDEA Community Edition 2020.3.3\lib\idea_rt.jar=58375:C:\Program Files\JetBrains\IntelliJ
IDEA Community Edition 2020.3.3\bin" - Dfile.encoding=UTF-8 -classpath
C:\Users\dell\IdeaProjects\furstjavacode\out\production\furstjavacode com.company.first

Enter

the

length

of

rectangl

e2
Enter the

breadth

of

rectangle

Ente

r the

Side

of

squa

re 3

Enter

the

radius

of the

circle 3

28.259999999999998

Process finished with exit code 0


Learning outcomes (What I

have learnt): 1.use of

inheritance

2. working of interfaces

You might also like