参考:http://blog.csdn.net/gxzzxj/article/details/51946144

下面是自己的代码:

public class ChildA extends Father {
void add() {
System.out.println("A中的ADD");
}
}
public class ChildB extends Father {
void add() {
System.out.println("B中的ADD");
}
}
import org.apache.catalina.filters.AddDefaultCharsetFilter;

public class Father {
public Father() {
System.out.println(this);
}
void add() {
System.out.println("父类中的ADD");
} }
public class Main {
public static void main(String[] args) {
Father a = new ChildA();
a.add();
}
}

参考博客的代码及结果

public class Father1 {
private int a = 10; Father1() {
System.out.println(this instanceof Son);
System.out.println(this.a);
System.out.println(((Son) this).a);
System.out.println(this.getClass().getName());
} public static void main(String[] args) { Father1 s = new Son();
System.out.println(s.a);
}
}
class Son extends Father1 {
public int a = 0;
public int b = 1;
public Son() {
//隐式调用super();
super();
System.out.println("Son类中执行:"+this);
} }

最新文章

  1. UVALive 4998 Simple Encryption --DFS
  2. Spring 下载与安装以及spring 3.2.9 jar包详解
  3. (转)SQL Server 的事务和锁(一)
  4. Extjs的radio单选框的使用
  5. NOIP200304麦森数
  6. CSS笔记(十三)CSS3之过渡
  7. DCL_数据库控制语言
  8. 函数fold 或reduce用法
  9. 【百度地图API】如何进行地址解析与反地址解析?——模糊地址能搜索到精确地理信息!
  10. Save Update saveOrUpdate delete
  11. 关于S/4HANA里Sales Office 和Sales Organization那些事儿
  12. Linux内核编译时会遇到的问题--缺少mkimage
  13. docker php容器中简单添加seaslog拓展
  14. Spring事务的传播:PROPAGATION_REQUIRED
  15. Linux下源码安装xz的方法
  16. JavaWeb过滤器.监听器.拦截器-原理&区别(转)
  17. Maven环境配置及简单使用(二)
  18. jsonp 接口
  19. FireDAC 下的 Sqlite [3] - 获取数据库的基本信息
  20. MySQL数据库服务器整体规划(go)

热门文章

  1. 【postgresql】postgresql中的between and以及日期的使用
  2. how to avoid over-fitting?(机器学习中防止过拟合的方法,重要)
  3. [NPM] Set default values for package.json using npm set
  4. Android自己定义View基础篇(三)之SwitchButton开关
  5. Servlet的部署开发细节以及注意事项
  6. PHP读取excel(6)
  7. 【第四篇章-android平台MediaCodec】解决Observer died. Quickly, do something, ... anything...
  8. 诊断并解决 ORA-4030 错误 (Doc ID 1548826.1)
  9. Django-配置celery
  10. 距特征之k阶距概念