Difference between Protected Property and Private Property | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Difference between Protected Property and Private Property

What is the difference between Protected Property and Private Property in Kotlin Class?

23rd Aug 2019, 7:59 AM
Plaban Kr. Mondal
Plaban Kr. Mondal - avatar
1 Resposta
+ 3
Protected The second level is ā€œprotected.ā€ Protected properties and methods can be accessed from inside the class they are declared, or in any class that extends them. They canā€™t be accessed from outside the class or subclass. Private While protected properties and methods are accessible anywhere in the object, the third level ā€œprivateā€ is more restrictive. A private property or method canā€™t be accessed by a subclass of the class it is defined in. If you have a class with a protected property and a private property and then extend that class in the subclass, you can access the protected property, but not the private property. Hope you may understand~
23rd Aug 2019, 8:08 AM
Uchiha Itachi
Uchiha Itachi - avatar