1.
Super class
package college;
abstract class college1 {
String name ;
String department;
public college1() {
name = "salaeh";
department = "d. mohamed";
public college1(String nam,String dep) {
name = nam;
department = dep;
abstract void fun();
2. Subclass (students):
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package college;
/**
*
* @author AHMED
*/
public class student extends college1 {
public student(){
super();
}
public student(String student_name,String student_dep){
super(student_name,student_dep);
}
void fun(){
[Link]("abstract function");
}
public void inform (String nam){
[Link]("student name is");
[Link](nam);
}
public void inform (String nam,String dep){
[Link]("student name is");
[Link](nam);
[Link]("student depart is");
[Link](dep);
}
3. Subclass (doctors)
package college;
public class doctors extends college1 {
String doctor_name;
String doctor_depart;
void fun(){
[Link]("abstract function");
}
public doctors() {
super();
}
public doctors(String doctor_name, String doctor_depart) {
super(doctor_name,doctor_depart);
}
public void inform (String nam){
[Link]("doctor name is");
[Link](nam);
}
public void inform (String nam,String dep){
[Link]("doctor name is");
[Link](nam);
[Link]("doctor depart is");
[Link](dep);
}
}
4. Class test
package college;
public class test {
public static void check(Object obj){
if (obj instanceof doctors){
[Link]("this is doctor class ");
}
if (obj instanceof doctors){
[Link]("this is student class ");
}}
public static void main(String[] args){
doctors doc;
doc = new doctors();
check(doc);
[Link]();
[Link]([Link], [Link]);
student st;
st = new student();
check(st);
[Link]();
[Link]([Link], [Link]);
}