publicclassPerson{staticintcount=0;Person(){count++;}publicvoidShow(){System.out.println("本类名="+this.getClass().getName()+";");System.out.println("父类名="+this.getCla...
public class Person
{
static int count=0;
Person(){
count++;
}
public void Show()
{
System.out.println("本类名="+this.getClass().getName()+";");
System.out.println("父类名="+this.getClass().getSuperclass().getName());
System.out.println("person.count="+this.count);
System.out.println("student.count="+Student.count);
}
}
class Student extends Person
{
static int count=0;
Student(){
super();
count++;
}
public void Show()
{
super.Show();
System.out.println("本类名="+this.getClass().getName()+";");
System.out.println("父类名="+this.getClass().getSuperclass().getName());
System.out.println("Student.count="+count);
}
public static void main(String[] arge)
{
Person pe=new Person();
pe.Show();
Student stu=new Student();
stu.Show();
}
}
展开