Home > Back-end >  Write a program between father and son class constructor call
Write a program between father and son class constructor call

Time:09-22

Pray god help me write such a program. Thanks

CodePudding user response:

Is anyone here,,,

CodePudding user response:

Pray god to help,

CodePudding user response:

~ 11111

CodePudding user response:

refer to the original poster wenzgh response:
beg god to help write such a program thank



Really don't understand what you said is what, subclass when initialized automatically calls the superclass constructor, the constructor is used during initialization,

CodePudding user response:

 
Public class Student {
A String of major;

Public Student () {
super();//call the superclass constructor
}

}




In addition, the parent class structure can't call a subclass constructor,
There is only one parent, but subclasses may have multiple,

CodePudding user response:

reference 5 floor addHao reply:
in addition, the parent class structure can't call a subclass constructor,
There is only one parent, but subclasses may have multiple,



Not parent can't call a subclass constructor, was once called subclass will automatically call the superclass constructor again, this becomes infinite loop dolls,
  • Related