Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

1|Page

Government Polytechnic, Washim


A
MICRO PROJECT REPORT
ON
“Calculate Area Of Any Type Of Shape Using Abstract Class”
OF
Subject: Advance java programing (22517)

Submitted By
Roll NO. Name Enrollment no.
52 Abhishek Ananta Borkar 2000310202

Subject Teacher H.O.D.


Mr. M. S. Hule Mr. U. A. Bagade
Lecturer in Info. Tech. Department Info. Tech. Department

Principal
Dr. B. G. Gawalwad
Government Polytechnic Washim
DEPARTMENT OF INFORMATION TECHNOLOGY
Term I 2022-2023
2|Page

Government Polytechnic Washim


CERTIFICATE
This is to certify that
Abhishek Ananta Borkar
Third year Student of Information Technology has submitted a MICRO PROJECT
Report on
“Calculate Area Of Any Type Of Shape Using Abstract Class.”

During the academic session 2022-2023 in a satisfactory manner in the partial


Fulfillment for the requirement of Subject:Advance java programing
Sub code(22517)

For the Diploma in “Information Technology”


Awarded by
Maharashtra State Board of Technical Education, Mumbai

Subject Teacher H.O.D.


Mr. M. S. Hule Mr. U. A. Bagade
Lecturer in Info. Tech. Department Info. Tech. Department
Principal
Dr. B. G. Gawalwad
Government Polytechnic Washim
DEPARTMENT OF INFORMATION TECHNOLOGY
Term I 2022-2023
3|Page

INTEX

Sr.No Title Page no.


1 Abstract: 4
Abstract method:

2 Procedure: 5
3 Rules For Abstract Class in Java 6
4 Source code 7-8
5 Area of future Improvement: 9
6 Conclusion: 9
4|Page

Abstract:
Abstraction in JAVA shows only the essential attributes and hides unnecessary details
Of the object from the user. In Java, abstraction is accomplished using Abstract class,
Abstract methods, and Interfaces. Abstraction helps in reducing programming
Complexity and effort.
ABSTRACT CLASS is a type of class in Java, that declare one or more abstract
Methods. These classes can have abstract methods as well as concrete methods. A normal
Class cannot have abstract methods. An abstract class is a class that contains at least one
Abstract method.

Abstract method:
An abstract method is a method that is declared without an implementation (without braces,
and followedby a semicolon), like this:
Abstract type name(parameter-list);
If a class includes abstract methods, then the class itself must be declared abstract. When an
abstract method appears in a class, the method must be overridden in a subclass. If a subclass
fails to override the method, an error will result. Abstract methods are used to ensure that a
subclass implements the method.
Using an abstract class, you can improve the Shape class shown earlier. Since there is no
meaningful concept of area for an undefined two-dimensional shape, the following version of
the program declares getArea( ) as abstract inside Shape. This, of course, means that all classes
derived from Shape must override getArea( ).
5|Page

Procedure:
1. Create an abstract class named shape that contains two integers and an empty method
named printarea().

2. Provide three classes named rectangle, triangle and circle such that each one of the
classes extends the class Shape.

3. Each of the inherited class from shape class should provide the implementation for the
method printarea().

4. Get the input and calculate the area of rectangle,circle and triangle .

5. In the shapeclass , create the objects for the three inherited classes and invoke the
methods and display the area values of the different shapes.
6|Page

Advantages of Abstraction:

i. Abstract class in Java is highly beneficial in writing shorter codes.


ii. Abstraction in Java avoids code duplication.
iii. Abstract classes enable code reusability.
iv. Changes to internal code implementation are done without affecting classes.

Rules For Abstract Class in Java are as follows:


7|Page

Source code of program:

Import java.lang.Math;
Abstract class Shape
{
Abstract void area();
Double area;
}
Class Triangle extends Shape
{
Double b=50,h=15;
Void area()
{
Area = (b*h)/2;
System.out.println(“area of Triangle ”+area);
}
}
Class Rectangle extends Shape
{
Double w=70,h=20;
Void area()
{
Area = w*h;
System.out.println(“area of Rectangle ”+area);
}
}
Class Circle extends Shape
8|Page

{
Double r=5;
Void area()
{
Area = Math.PI * r * r;
System.out.println(“area of Circle ”+area);
}
}
Class Area
{
Public static void main(String [] args)
{
Triangle t= new Triangle();
Rectangle r =new Rectangle();
Circle c =new Circle();
t.area();
r.area();
c.area();
}
}
9|Page

Area of future Improvement:


For future, in a project specially for larger projects and many class files in a abstract
Class can be created for different uses like in a main file for importing arithmetic
Operations, classes can be created named arithmetic_operations in which different
Class file for different operations like addition, subtraction, multiplication etc. can be
Created and for string operations package named string_operation can be developed
For operations like reversing, finding length, concatenating etc. can be made.

Conclusion:
We learn to calculate area of various shape. Also, we developed a java file and learnt
Various syntax in java
10 | P a g e

You might also like