Define a package named myInstitute include class named as Department with one method to display the staff of the department. Develop a program to import this package in a java application and call the method define in the package.
Code:
package myInstitute;
public class Department
{
public void
display()
{
int sr=1;
String
Name="Ajay";
long
no=987654321;
String
desig="H.O.D";
System.out.println("Details
of Staff are");
System.out.println("Srno
= "+sr);
System.out.println("Name
= "+Name);
System.out.println("Designation
= "+desig);
System.out.println("Phone
Number = "+no);
}
}
import myInstitute.*;
class JavaApplication
{
public static
void main(String args[])
{
Department obj
= new Department();
obj.display();
}
}
Output:
Comments
Post a Comment