package javaClassStudy;

/**
*
* @author yuxg
* 抽象类实践
*/
public abstract class Person {
private String name ;
private int age; public Person(String name, int age) {
this.name = name;
this.age = age;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public void setAge(int age) {
this.age = age;
} public int getAge() {
return age;
}
public abstract String getDescription();//描述
public abstract void live();//live }
package javaClassStudy;

/**
*
* @author Administrator
*/
public class Student extends Person { public Student(String name, int age) {
super(name, age);
} @Override
public String getDescription() {
System.out.println("Name is:"+this.getName());
return "Name is:" + this.getName();
} /**
*
*/
@Override
public void live() {
System.out.println("I live in a big house!"+this.getName());
} }
/**
*
* @author Administrator
*/
import javaClassStudy.Student;
import javaClassStudy.Person;
public class helloWorld {
public static void main(String[] parm){
Person p = new Student("yuxg",12);
p.live();
System.out.println(p.getDescription() );
} }
04-25 12:37