38 - Extends ( super constructor ) | Java Tutorials

preview_player
Показать описание
Teaches you how-to use the extends keyword in java to make your child class inherit all the public methods and data fields in the parent class.

| Language
Java (.java /.class)

| Code Example
Рекомендации по теме
Комментарии
Автор

Couple notes:
1. Don't worry about writing the code down we'll be changing it up as these tutorials go more in-depth. I'll provide the final code at the end. 
2. A child class cannot extend more than one parent. (semi-workarounds available)
3. A parent can have infinite children. ex: the Mammal class has dog and cat class.

SimplyCoded
Автор

Im a bit confused. You first say by using cat extends dog can access all datafields (and methods) in dog class, later saying "its kinda being copied". Then you say instead of copying the data fields (and the content of the super constructor) into the subclass, you can call super constructor? So is the declaration of datafields copied/inherited by using the extends keyword or by the super()?

H-vi