0% found this document useful (1 vote)
2K views4 pages

Java Practical No.20 PDF

The document describes two Java programs that define and call methods from packages. The first program defines a package "myInstitute" with a class "department" that has a method to display staff names. The second program defines a package "let_me_calculate" with a class "calculator" that has a method to add two integers. Both programs import and call the methods from the respective packages.

Uploaded by

Meer Kukreja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
2K views4 pages

Java Practical No.20 PDF

The document describes two Java programs that define and call methods from packages. The first program defines a package "myInstitute" with a class "department" that has a method to display staff names. The second program defines a package "let_me_calculate" with a class "calculator" that has a method to add two integers. Both programs import and call the methods from the respective packages.

Uploaded by

Meer Kukreja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

➢ Define a package named myInstitute include class named as department with

one method to display the staff of that department. Develop a program to import
this package in a java application and call the method defined in the package.

package myInstitute;

public class department

public void display()

System.out.print("Name of Staff is \n 1. Rajesh \n 2. Ram \n 3. Ramesha \n 4.


Rahul ");

import myInstitute.*;

class mydep

public static void main(String args[])

department d=new department();

d.display();

}
➢ Develop a program which consist of the package named let_me_calculate with a
class named calculator and a method named add to add two integer number.
Import let_me_calculate package in another program (class named Demo) to add
two numbers.

package let_me_calculate;

public class calculator

int x,y,z;

public void add(int a,int b)

x=a;

y=b;

z=x+y;

System.out.print("Addition of "+x+" and "+y+" : "+z);

import let_me_calculate.*;

class demo

public static void main(String args[])

calculator c=new calculator();

c.add(10,20);

You might also like