java面试题

当前位置: 面试问题网 > java面试题 > super()与this()的区别

super()与this()的区别

This():当前类的对象,super父类对象。
   Super():在子类访问父类的成员和行为,必须受类继承规则的约束
   而this他代表当前对象,当然所有的资源都可以访问.
   在构造函数中,如果第一行没有写super(),编译器会自动插入.但是如果父类没有不带参数的构造函数,或这个函数被私有化了(用private修饰).此时你必须加入对父类的实例化构造.而this就没有这个要求,因为它本身就进行实例化的构造.
   而在方法中super和this使用的方法就差不多了.只不过super 要考虑是否能访问其父类的资源.

【super()与this()的区别】相关文章

1. super()与this()的区别

2. super关键字的用法

3. What\'s the difference between Debug and Trace class? (Debug类与Trace类有什么区别)

4. 关键字throw与throws的用法差异

5. Does C# support multiple inheritance? (C#支持多重继承吗)

6. 说说在weblogic中开发消息Bean时的persistent与non-persisten的差别

7. 软件测试LoadRunner面试题:How did you find web server related issues?

8. 软件测试LoadRunner面试题:How do you identify the performance bottlenecks

9. 软件测试LoadRunner面试题:What is think time? How do you change the threshold?

10. 软件测试LoadRunner面试题:If web server, database and Network are all fine where could be the problem?

本文来源:https://www.mianshiwenti.com/a12324.html

点击展开全部

《super()与this()的区别》

将本文的Word文档下载到电脑,方便收藏和打印

推荐程度:

进入下载页面

﹝super()与this()的区别﹞相关内容

「super()与this()的区别」相关专题

其它栏目

也许您还喜欢