您的位置:首页 > 其它

抽象类可以没有抽象方法,不能被实例化

2010-07-02 10:05 316 查看
抽象类可以没有抽象方法,不能被实例化

father class

/**
*
*/
package testAbstract;
/**
* @author 2172980000502
*
*/
public abstract class Father {
protected void fatherSay() {
// TODO Auto-generated method stub
System.out.println("I am a father class!");
}
}


son class

/**
*
*/
package testAbstract;
/**
* @author 2172980000502
*
*/
public class Son extends Father {
protected void sonSay() {
// TODO Auto-generated method stub
System.out.println("I am a son class!");
}
}


应用入口

/**
*
*/
package testAbstract;
/**
* @author 2172980000502
*
*/
public class TestAbstract {
/**
* @param args
*/
public static void main(String[] args) {
// father class can not been new
// Father f = new Father();

Son s = new Son();
s.sonSay();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐