package java_samples_hwang;
/**
*
* @author hwang
*/
class Base {
int id;
String sName;
public void setData(int Id,String Name)
{
id = Id; sName = Name;
}
}
class student extends Base
{
String sInstitution;
public void setInstitute(String s)
{
sInstitution = s;
}
public void printData()
{
System.out.println("The Student Details are.....");
System.out.println("Student ID: "+ id);
System.out.println("Student NAME: "+sName);
System.out.println("Institution: "+ sInstitution);
}
}
class employee extends Base
{
String sOrganization;
public void setOrg(String s)
{
sOrganization = s;
}
public void printData()
{
System.out.println("The Employee Details are.....");
System.out.println("Emp ID: "+ id);
System.out.println("Emp NAME: "+sName);
System.out.println("Organization: "+ sOrganization);
}
}
public class InheritanceDemo
{
public static void main(String args[])
{
student stdobj = new student();
stdobj.setData(5, "Minho");//base class method
stdobj.setInstitute("st.John");
stdobj.printData();
employee empobj = new employee();
empobj.setData(1201, "Hwang");//base class method
empobj.setOrg("Wipro");
empobj.printData();
}
}
'백엔드기술 > 개발언어' 카테고리의 다른 글
ConstructorEx (0) | 2009.12.09 |
---|---|
Connect sample (0) | 2009.12.09 |
ArrayDemo (0) | 2009.12.09 |