Java Tutorial #6: Protected vs. Private

preview_player
Показать описание
In this java tutorial I discuss how to use protected properties and how they differ from private properties. [MORE BELOW]

If you have any questions leave a comment below and I will get back to you as soon as possible.

SUBSCRIBE! for more videos!
Рекомендации по теме
Комментарии
Автор

Excellent and clear explanation. Thanks a bunch!

dogetinos
Автор

well u could create the method getName in class Animal. That way it would just inherit this method as well.. but yeah there are some cases where it's needed and that's a nice simple example to get introduced to the concept of protected.

ZoroTV
Автор

Trying to throw everything in for the APCS A test. Coming up May 17th

youtubeaccountx
Автор

i tried to figure this out for the whooollee day and it was ur video that made me " 0_0 h- *gasp* 0o0 this what its all about!"
thank you man fghfg

senaustun
Автор

The main purpose of protected is that the variable declared protected will be accessible within a package.

mazymetric
Автор

So...if you want the name and it is protected you don't need to make a get method to return it but you just use "extends" right? We always have to use inheritance with a protected variable?

sandy
Автор

If we declare no modifier for a variable then also that variable can be used in sub classes and won't be visible to other classes. So the purpose can be served by default modifier also, i.e., by not specifying any modifier to the variable. Then why should we declare that variable as protected ?

sagarshinde
Автор

You did not explain it fully... what happens when you are on the derived class abd want to access an instance variable of a base clase (which is protected) by using a different object ? .... you skiped the crutial part I guess

instaminox
join shbcf.ru