冰
冰力不足
Unregistered / Unconfirmed
GUEST, unregistred user!
//testStudent.java
class Person
{
protected String strName;
protected int nAge;
protected int nSex;
public Person (String name,int age,int sex)
{
strName = name;
nAge = age;
nSex = sex;
}
public String getName()
{
return strName;
}
public int getSex()
{
return nSex;
}
public void setName(String name)
{
strName = name;
}
public void setAge(int age)
{
nAge = age;
}
public void setSex(int sex)
{
nSex = sex;
}
public void print()
{
System.out.println("我的名字叫 "
+ strName + "
,我今年 "
+ nAge + "
岁."
}
}
class Student extends Person
{
protected String strNum;
public String getNum()
{
return strNum;
}
public void setNum(String num)
{
strNum = num;
}
}
public class testStudent
{
public static void main(String arg[])
{
Person p = new Person("冰力不足",29,2);
p.setAge(25);
p.print();
Student s = new Student();
s.setName("李藜"
s.setAge(20);
s.setSex(1);
s.setNum("000899"
s.print();
System.out.println("我的学号是 "+s.getNum());
}
}
提示39行 class Student extends Person 有错
class Person
{
protected String strName;
protected int nAge;
protected int nSex;
public Person (String name,int age,int sex)
{
strName = name;
nAge = age;
nSex = sex;
}
public String getName()
{
return strName;
}
public int getSex()
{
return nSex;
}
public void setName(String name)
{
strName = name;
}
public void setAge(int age)
{
nAge = age;
}
public void setSex(int sex)
{
nSex = sex;
}
public void print()
{
System.out.println("我的名字叫 "
+ strName + "
,我今年 "
+ nAge + "
岁."
}
}
class Student extends Person
{
protected String strNum;
public String getNum()
{
return strNum;
}
public void setNum(String num)
{
strNum = num;
}
}
public class testStudent
{
public static void main(String arg[])
{
Person p = new Person("冰力不足",29,2);
p.setAge(25);
p.print();
Student s = new Student();
s.setName("李藜"
s.setAge(20);
s.setSex(1);
s.setNum("000899"
s.print();
System.out.println("我的学号是 "+s.getNum());
}
}
提示39行 class Student extends Person 有错