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.

import useFul.UseMe;

class PackageUse
 public static void main(String b[])
  UseMe um = new UseMe();
C:\>java PackageUse
Length of Rectangle = 12.0
Breadth of Rectangle = 7.0
Area of Rectangle = 84.0


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.

Program to input age from user and throw user-defined exception if entered age is negative

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.