Professional Documents
Culture Documents
AJP Micro Project
AJP Micro Project
Submitted By
Roll NO. Name Enrollment no.
52 Abhishek Ananta Borkar 2000310202
Principal
Dr. B. G. Gawalwad
Government Polytechnic Washim
DEPARTMENT OF INFORMATION TECHNOLOGY
Term I 2022-2023
2|Page
INTEX
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:
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
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