output
1: Create package <abc> with <employee> class
package abc;
public class employee{
String name=”Aryan”;
String design=”Developer”;
public void show(){
System.out.println(“******************* Detail **********************”);
System.out.println(“Name : “+name+”\tDesignation : “+design);
System.out.println(“************************************************”);
}
}
2. Create 2nd package <def> with class <department>
package def;
import java.util.Scanner;
import abc.employee;
public class department extends employee{
String dept;
public void show(){
Scanner x=new Scanner(System.in);
System.out.println(“\nEner D1 -> D2 -> -> D3”);
dept=x.nextLine();
if(dept.matches(“d1”))
{
System.out.println(“***************** Department : CSE *****************”);
}
if(dept.matches(“d2”))
{
System.out.println(“**************** Department : MECH ****************”);
}
if(dept.matches(“d3”))
{
System.out.println(“***************** Department : IT *********************”);
}
}
}
3. Import <abc> and <def> package in class <hello>
import abc.employee;
import def.department;
public class hello{
public static void main(String[] args)
{
employee dt=new department();
employee emp=new employee();
emp.show();
dt.show();
}
}
}
}
