qinglouchangke
2021-01-25 01:52这段代码的打印过程是怎样的,我是小白,恳求诸位大佬指点一下
package LSQ;
class SuperClass{
int x;
SuperClass(){
x = 3;
System.out.println("in SuperClass:x=" + x);
}
void doSomething(){
System.out.println("in SuperClass.doSomething()");
}
}
class SubClass extends SuperClass{
int x;
SubClass(){
super();
x = 5;
System.out.println("in SubClass:x=" + x);
}
void doSomething(){
super.doSomething();
System.out.println("in SubClass.doSomething()");
System.out.println("super.x=" + super.x + " sub.x=" + x);
}
}
public class Star2{
public static void main(String[] args){
SubClass subC = new SubClass();
subC.doSomething();
}
}
- 点赞
- 回答
- 收藏
- 复制链接分享
3条回答
为你推荐
- 求大佬解决Python问题中的EOF报错问题
- python
- 1个回答
- python中导入import matplotlib.pyplot as plt 报错应该怎么解决?
- python
- 1个回答
- 用python+opencv把照片中的人像抠出来,然后换个纯色的背景,谁会编写这样的代码?求助
- python
- 人工智能
- 3个回答
- SQL查询——现有如下需求,不知能否实现,恳求各位帮忙
- 数据库
- mysql
- 0个回答
- java和C/C++待遇薪资疑惑
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
换一换