由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - who can help me with this dummy Question??
相关主题
一道java题请教一个简单的问题
问题征解Java练习题 5
求教一个Java问题 IllegalMonitorStateExceptionlocal变量被赋值了几次?
java的一个问题菜鸟问个简单的问题
问个基本问题请教大家:如何modify java code in order to compile
extending generic class , but not mentioning its parameterized type?Re: 如何在两个窗口之间通信?
这个程序为什么先打印hellomyworld,而不是args【0】?how to access the overrided fields of the parent?
有关thread in Java问一个 java generic问题
相关话题的讨论汇总
话题: child话题: parent话题: public话题: question话题: dummy
进入Java版参与讨论
1 (共1页)
t****r
发帖数: 25
1
Parent.java:
public class Parent {
public Parent() {
System.out.println("parent");
}
}
Child.java:
public class Child extends Parent {
public Child() {
System.out.println("child");
}
public static void main(String[] args) {
Child c = new Child();

}
}
java Child, outputs:
parent
child
WHY??
g*s
发帖数: 2277
2
If you don't call super(xxx) or this(xxx) as the first line of code in a
constructor, Java will automatically insert a call to the default no-
argument superclass constructor super() for you.

【在 t****r 的大作中提到】
: Parent.java:
: public class Parent {
: public Parent() {
: System.out.println("parent");
: }
: }
: Child.java:
: public class Child extends Parent {
: public Child() {
: System.out.println("child");

g*s
发帖数: 2277
3
If you don't call super(xxx) or this(xxx) as the first line of code in a
constructor, Java will automatically insert a call to the default no-
argument superclass constructor super() for you.

【在 t****r 的大作中提到】
: Parent.java:
: public class Parent {
: public Parent() {
: System.out.println("parent");
: }
: }
: Child.java:
: public class Child extends Parent {
: public Child() {
: System.out.println("child");

B******N
发帖数: 445
4
you can use a debugger to step through, which will help you to understand
the instantiation sequence of every bit, and that will help you to
understand more OO.

【在 t****r 的大作中提到】
: Parent.java:
: public class Parent {
: public Parent() {
: System.out.println("parent");
: }
: }
: Child.java:
: public class Child extends Parent {
: public Child() {
: System.out.println("child");

1 (共1页)
进入Java版参与讨论
相关主题
问一个 java generic问题问个基本问题
这几个函数可以用Generic之类的东西合并么?extending generic class , but not mentioning its parameterized type?
有熟悉Java Reflection的吗这个程序为什么先打印hellomyworld,而不是args【0】?
Java的method不都是virtual的么?private就不同了?有关thread in Java
一道java题请教一个简单的问题
问题征解Java练习题 5
求教一个Java问题 IllegalMonitorStateExceptionlocal变量被赋值了几次?
java的一个问题菜鸟问个简单的问题
相关话题的讨论汇总
话题: child话题: parent话题: public话题: question话题: dummy