package ClassTest;
class Students extends myTest
{
String address;
/*public Students(){
super("張曼玉",60);
System.out.println("輸出Students");
} */
public Students(String name,int age,String address){
super.name = name;
super.age = age;
this.address = address;
System.out.println(super.talk()+" "+this.address);
}
}
public class myTest {
String name;
int age;
public myTest() {
// TODO Auto-generated constructor stub
System.out.println("輸出myTest");
}
public myTest(String name,int age){
this.name = name;
this.age = age;
}
public String talk(){
return "姓名: "+this.name+" 年齡: "+this.age;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
myTest mt = new myTest();
mt.name = "張三";
mt.age = 28;
System.out.println("名字->"+mt.name+":年齡->"+mt.age);
Students st = new Students("姚明",35,"上海體育中心");
/* st.name = "張三2";
st.age = 28;
st.address = "上饒銀行佳麗商城中心";
System.out.println("名字->"+st.name+":年齡->"+st.age+":地址->"+st.address); */
st.talk();
}
}