protected修饰的成员属性和方法的可见范围:子类或同一个包中的类
来源:互联网 发布:淘宝店铺首页图片尺寸 编辑:程序博客网 时间:2024/06/06 03:46
If a method or instance variable is modified by protected (rather than public or
private), then it can be accessed by name inside its own class definition, it can be
accessed by name inside any class derived from it, and it can also be accessed by name
in the definition of any class in the same package (even if the class in the same package
is not derived from it). However, the protected method or instance variable cannot be
accessed by name in any other classes. Thus, if an instance variable is marked protected
Child. However, in a class that is not in the same package as Parent and is not derived
from Parent, it is as if the protected instance variable were private.
private), then it can be accessed by name inside its own class definition, it can be
accessed by name inside any class derived from it, and it can also be accessed by name
in the definition of any class in the same package (even if the class in the same package
is not derived from it). However, the protected method or instance variable cannot be
accessed by name in any other classes. Thus, if an instance variable is marked protected
in the class Parent and the class Child is derived from the class Parent, then the
instance variable can be accessed by name inside any method definition in the classChild. However, in a class that is not in the same package as Parent and is not derived
from Parent, it is as if the protected instance variable were private.
0 0
- protected修饰的成员属性和方法的可见范围:子类或同一个包中的类
- Java中继承时的问题——子类和父类在(或不在)同一个包中的继承
- OC-010.OC类中的修饰可见性的关键字@private、@protected、@public
- 关于子类无法访问父类protected属性和方法的问题
- java中的4个修饰符default/public/protected/private的作用和作用范围
- php类函数和成员方法的可见性和属性
- js中的子类继承父类的方法和属性
- JAVA方法访问修饰和类的成员访问修饰
- 被protected修饰的属性/方法在何处可以访问?
- 面试题:说说Java中接口、类、成员变量、成员方法、构造方法有哪些访问修饰符和他们的作用范围
- js属性和方法的可见性:私有属性(方法),实例属性(方法),类属性(方法)
- java类成员属性修饰符default, public, private, protected
- Java中的类、成员变量及方法的修饰符
- Java private和protected修饰的内部类调用方法
- 类中的成员属性和成员方法
- C#中的类,子类,类的继承,重构,虚方法,protected(续)
- 【Java关键字-访问范围修饰符】private、protected、public和default的区别
- 类的成员 protected和 private 区别
- 黑马程序员《java基础总结(一)》(java概述与基础语法)
- asp.net mvc 3.0详细笔记__02__项目文件结构概述
- oracle undo解析
- Poj 1730 Perfect Pth Powers (数论 GCD)
- 使用PostThreadMessage在Win32线程间传递消息
- protected修饰的成员属性和方法的可见范围:子类或同一个包中的类
- 在Eclipse环境下配置Servlet开发环境(伪原创)
- ZOJ-3207
- 熊猫的成长
- DSP 基础问答
- java面试笔记02
- <SVN基本设置>构建单机SVN
- OpenGL坐标系
- GAC的理解及其作用