We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
4th experiment
AIM: To write a Java program to calculate the area of rectangle, circle
and triangle using the concept of abstract class. ALGORITHM: Step 1: Start the program. Step 2: Create an abstract class named shape that contains two integers and an empty method named printArea(). Step 3: Create three classes named rectangle, triangle and circle such that each one of the classes extends the class Shape. Step 4: Each of the inherited class from shape class should provide the implementation for the methodprintArea(). Step 5: In printAree() method get the input from user and calculate the area of rectangle, circle and triangle. Step 6: In the AbstractArea, create the objects for the three inherited classes and invoke the methods and display the area values of the different shapes. Step 7: Stop the program. 5th experiment
AIM: To write a Java program to calculate the area of rectangle, circle
and triangle by implementing the interface shape. ALGORITHM: Step 1: Start the program. Step 2: Create an interface named shape that contains an empty method named printArea(). Step 3: Create three classes named rectangle, triangle and circle such that each one of the classes implements the class Shape. Step 4: Each of the class should provide the implementation for the method printArea(). Step 5: In printAree() method get the input from user and calculate the area of rectangle, circle and triangle. Step 6: In the TestAreaclass , create the objects for the three classes and invoke the MethodprintArea() and display the area values of the different shapes. Step 7: Stop the program