1

00:00:01,050  -->  00:00:06,480
End this demo I'm going get the monster I feel hiding as well as the overall lighting effect that we

2

00:00:06,480  -->  00:00:06,690
can.

3

00:00:06,690  -->  00:00:10,450
How do you feel re-assignment in a subclass.

4

00:00:10,530  -->  00:00:12,280
So this is a user or Jawa.

5

00:00:12,510  -->  00:00:14,430
And here we have two instance variables.

6

00:00:14,430  -->  00:00:16,980
One is ID and the other is user type.

7

00:00:17,050  -->  00:00:21,150
So the idea for this comes from the previous run one of the previous demos.

8

00:00:21,210  -->  00:00:22,830
It is initialized to 1.

9

00:00:23,070  -->  00:00:30,240
And in the subclass staff we are really clearing ID and initializing it to in the support class it was

10

00:00:30,270  -->  00:00:31,850
initialized to 1.

11

00:00:31,860  -->  00:00:38,370
Now we also to introduce this new variable called user type and it is initialized to user unstaffed

12

00:00:38,370  -->  00:00:39,450
or Djala.

13

00:00:39,450  -->  00:00:46,480
We have introduced this constructor and here we are re initializing user type stuff.

14

00:00:46,530  -->  00:00:47,200
OK.

15

00:00:47,610  -->  00:00:53,970
And then use about Djala and new numerator called display user info has been added and it simply Prendes

16

00:00:54,120  -->  00:00:56,620
all the user attributes in this guess.

17

00:00:56,640  -->  00:01:02,880
There are only two attributes the ID and user type and it simply print them and then user does our job

18

00:01:02,880  -->  00:01:04,540
which is a tester to us.

19

00:01:04,620  -->  00:01:11,780
We are creating an instance of staff and a reference type is user and we are simply invoking the method

20

00:01:11,820  -->  00:01:13,500
display user in for.

21

00:01:13,530  -->  00:01:15,580
So let me just go ahead and run this.

22

00:01:15,900  -->  00:01:21,530
And here for I.D. It prints 1 and for user type prints stuff.

23

00:01:21,600  -->  00:01:23,180
So that's going to user.

24

00:01:23,240  -->  00:01:28,020
So for I.D. It is simply printing the value that is here.

25

00:01:28,020  -->  00:01:35,460
So it's not printing the real declared value in the subclass even though we are accessing the display

26

00:01:35,460  -->  00:01:38,820
user in format they're using a staff reference.

27

00:01:38,820  -->  00:01:45,270
So that's because the value is not overridden and ID when we access it here it will always try to access

28

00:01:45,750  -->  00:01:48,180
the ID field in the same class.

29

00:01:48,180  -->  00:01:50,990
So it's exactly like a static method.

30

00:01:51,000  -->  00:01:57,630
If you recall from our demo and in the previous lesson where the static methods cannot be overridden

31

00:01:57,630  -->  00:01:59,340
but only it can be hidden.

32

00:01:59,340  -->  00:02:04,560
So even there it was always accessing the static method in the same class.

33

00:02:04,590  -->  00:02:06,720
And that's exactly what is happening here.

34

00:02:06,840  -->  00:02:12,900
But with regards to user type the values being reassigned here in the constructor.

35

00:02:13,080  -->  00:02:18,320
And so we have only a single version of user type and we can see the overriding effect here.

36

00:02:18,390  -->  00:02:20,780
And the staff is getting printed.

37

00:02:20,820  -->  00:02:29,190
Now let's just as soon that this display user info method is installed on here it is inside the staff

38

00:02:29,190  -->  00:02:29,540
class.

39

00:02:29,550  -->  00:02:35,520
Let's just write it here and now for ID it's going to print.

40

00:02:35,880  -->  00:02:36,210
Oh

41

00:02:39,250  -->  00:02:47,250
you need to typecast us to staff.

42

00:02:48,020  -->  00:02:48,570
There you go.

43

00:02:48,570  -->  00:02:52,670
So for ID it is two and four user type it is once again staff.

44

00:02:52,710  -->  00:03:00,460
So for I.D. It was accessing the local ID value here in the same class and it's printing too.

45

00:03:00,810  -->  00:03:02,660
So that's about it.
