Program to create a class 'PackageUse' to import the above package 'useFul' and use the method area( )

In previous program, we have crated a package named useFul and added class UseMe in that package. Now in this program we use that package to import the class "UseMe" in class "PackageUse". Here we have used the area( ) method of UseMe class.


PROGRAM
import useFul.UseMe;

class PackageUse
{
 public static void main(String b[])
 {
  UseMe um = new UseMe();
  um.area(12,7);
 }
}
OUTPUT
C:\>javac PackageUse.java
C:\>java PackageUse
Length of Rectangle = 12.0
Breadth of Rectangle = 7.0
Area of Rectangle = 84.0

Comments

Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.

Program to draw Smiley in Applet