Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,630 --> 00:00:03,870
A top class can use the constructor of its parent class.
2
00:00:05,180 --> 00:00:08,750
The child class uses its constructor to update its fields.
3
00:00:10,970 --> 00:00:15,110
The child class uses the parent constructor to update inherited fields.
4
00:00:17,450 --> 00:00:20,900
In this lesson, each child, the class will call the parent constructor.
5
00:00:24,290 --> 00:00:28,700
Super refers to the super class, which also means parent class.
6
00:00:32,240 --> 00:00:38,000
Now, super with brackets refers to the constructor of the super class, the constructor of the parent
7
00:00:38,000 --> 00:00:38,630
class.
8
00:00:42,640 --> 00:00:46,000
If you want to call the constructor of a parent class, use super.
9
00:00:48,690 --> 00:00:52,200
An inside in the parameters that the constructor expects.
10
00:00:54,890 --> 00:00:59,570
Now, let's say our parent class, as of the following instructor, then this is how you would call
11
00:00:59,570 --> 00:01:01,940
the parent constructor pretty cool.
12
00:01:04,629 --> 00:01:08,560
Now, inside, man, we have two objects, put a break point and run the debugger.
13
00:01:21,840 --> 00:01:24,000
Creates a new object of the short class.
14
00:01:24,030 --> 00:01:24,510
OK.
15
00:01:26,090 --> 00:01:28,580
The child constructor receives four parameters.
16
00:01:32,810 --> 00:01:36,800
But it only updates one of them, the rest of them remain zero or no.
17
00:01:41,000 --> 00:01:46,460
Now, it's impossible to update inherited fields from the child constructor, the child class needs
18
00:01:46,460 --> 00:01:48,080
to use the parent constructor.
19
00:01:49,040 --> 00:01:52,820
So inside product Java, critic, instructor, public product.
20
00:01:55,450 --> 00:02:01,000
That receives three parameters, double price, string color, string, brand.
21
00:02:06,790 --> 00:02:12,940
And update each field in the current object with a parameter, the stock price equals price, this color
22
00:02:12,940 --> 00:02:13,690
equals color.
23
00:02:18,900 --> 00:02:20,280
This brand equals brand.
24
00:02:26,610 --> 00:02:32,250
OK, and now the child class needs to use the parent's constructor to update the fields that it inherits.
25
00:02:38,250 --> 00:02:41,940
You can refer to the superclass, the parent class using super.
26
00:02:45,560 --> 00:02:49,280
And you can refer to the super classes constructor by adding Brackett's.
27
00:02:50,970 --> 00:02:54,660
And inside, you can add three of the parameters into the super constructor.
28
00:02:59,670 --> 00:03:04,560
Now, the pants class also needs to use the parents constructor to update the fields that it inherits.
29
00:03:12,230 --> 00:03:14,480
And that's it now we get to run the debugger.
30
00:03:25,850 --> 00:03:28,250
It creates a new object of the short class.
31
00:03:29,510 --> 00:03:31,820
The constructor receives four parameters.
32
00:03:35,220 --> 00:03:38,010
It passes three of them into the parent constructor.
33
00:03:44,660 --> 00:03:50,270
The parent constructor updates three fields in the current object that's being created, and once the
34
00:03:50,270 --> 00:03:56,210
parent constructor is done, the child, the class uses its constructor to update its field.
35
00:04:01,660 --> 00:04:03,550
OK, moving on to the object.
36
00:04:06,980 --> 00:04:12,750
It creates a new object of the pants class, the constructor receives four parameters, three of them
37
00:04:12,750 --> 00:04:14,700
are passed into the parent constructor.
38
00:04:17,620 --> 00:04:22,270
The parent constructor updates three fields in the current object that's being created.
39
00:04:27,360 --> 00:04:29,310
And once the parent constructor is done.
40
00:04:30,790 --> 00:04:34,750
The child class is using its constructor to update its field.
41
00:04:38,100 --> 00:04:43,880
All right, let's go back to the subject of polymorphism inheritance allows an object to take many forms.
42
00:04:43,890 --> 00:04:47,520
In other words, inheritance allows an object to be polymorphic.
43
00:04:50,450 --> 00:04:56,900
Our shirt to class inherits from the product class so we can declare this as type products, our pants
44
00:04:56,900 --> 00:05:01,670
class also inherits from the product class so we can also declare it as type products.
45
00:05:02,390 --> 00:05:05,730
Now, you might be wondering, why is polymorphism useful?
46
00:05:06,530 --> 00:05:08,510
The answer to that is flexibility.
47
00:05:11,330 --> 00:05:17,840
Here we create an object of the class, and here we created an object of the pants class, but they're
48
00:05:17,840 --> 00:05:19,340
both of type product.
49
00:05:20,390 --> 00:05:22,830
So we can store them inside the same array.
50
00:05:23,180 --> 00:05:29,810
I can create an array of type product products is equal to a new array that can store product objects.
51
00:05:38,680 --> 00:05:40,210
And here I can put the shirt.
52
00:05:42,000 --> 00:05:43,020
And the pants.
53
00:05:50,860 --> 00:05:57,180
Although this is a shirt object and this is a pants object, each one is taking the form of a product
54
00:05:57,190 --> 00:05:57,760
object.
55
00:05:58,030 --> 00:05:59,410
This is polymorphism.
56
00:05:59,920 --> 00:06:05,020
A class can take its own form or it can take the form of the class it's inheriting from.
57
00:06:08,280 --> 00:06:11,490
A child class can use the constructor of its parent class.
58
00:06:14,270 --> 00:06:17,870
The child class uses its constructor to update its fields.
59
00:06:19,710 --> 00:06:23,820
And the child class uses the parent constructor to update inherited fields.
60
00:06:26,090 --> 00:06:31,790
Now, super with brackets refers to the constructor of the super class, the constructor of the parent
61
00:06:31,790 --> 00:06:32,300
class.
62
00:06:34,880 --> 00:06:38,420
If you want to call the constructor of a parent class, you super.
63
00:06:40,140 --> 00:06:43,710
And inside Passan, the parameters that the constructor expects.
6294
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.