有关继承相关的问题
class Person{
public String name="unknown";
public int age=-1;
public Person(String name,int age)
{
this.name=name ;
this.age=age;
}
public void getInFo()
{
System.out.println("name="+name+";age="+age);
}
}
class Student extends Person
{
public String school="unknown";
public Student(String name,int age)
{
super("hehe",21);
}
public void study()
{
}
}
class TestStudent
{
public static void main (String [] args)
{
Student st= new Student(); //为什么这里是错的?????????????
st.name="hehe";
st.school="南工大";
st.age=23;
st.getInFo();
}
}