| 1. |
Explain The Differences Between Public, Protected, Private And Internal. |
|
Answer» These all are access modifier and they governs the access LEVEL. They can be applied to class, methods, FIELDS. Public: Allows class, methods, fields to be accessible from anywhere i.e. within and OUTSIDE an assembly. Private: When applied to field and method allows to be accessible within a class. Protected: Similar to private but can be accessed by members of derived class also. INTERNAL: They are public within the assembly i.e. they can be accessed by anyone within an assembly but outside assembly they are not VISIBLE. These all are access modifier and they governs the access level. They can be applied to class, methods, fields. Public: Allows class, methods, fields to be accessible from anywhere i.e. within and outside an assembly. Private: When applied to field and method allows to be accessible within a class. Protected: Similar to private but can be accessed by members of derived class also. Internal: They are public within the assembly i.e. they can be accessed by anyone within an assembly but outside assembly they are not visible. |
|