class Person
{
protected int i=1;
int j=2;
}class Girl extends Person
{
public static void main(String[] args)
{
Person p=new Person();
Girl g=new Girl();
System.out.println(p.i);
System.out.println(g.i);
System.out.println(p.j);
System.out.println(g.j);
}
}上面的代码能编译运行,请问下默认访问权限和protected访问权限是一样的吗?
{
protected int i=1;
int j=2;
}class Girl extends Person
{
public static void main(String[] args)
{
Person p=new Person();
Girl g=new Girl();
System.out.println(p.i);
System.out.println(g.i);
System.out.println(p.j);
System.out.println(g.j);
}
}上面的代码能编译运行,请问下默认访问权限和protected访问权限是一样的吗?
解决方案 »
- thread pool问题
- 郁闷啊~SSH中,第一个添加功能可以,第二个查询功能spring配置文件不起作用
- 在线等待,求解:Access denied for user 'root'@'localhost' (using password: YES)
- 各位大侠救急呀 酒店接口的问题。
- 求问action A 如何调用action B 中的方法?(涉及B的初始化)
- 请问 @hibernate.composite-id 如何使用
- Mybatis映射DAO接口问题
- Javamail一个非常之怪的问题!不信你去试!
- 很菜鸟的问题:有关CMP Entity Bean的Relationship
- myeclipse项目怎么在现场服务器上部署?
- 请高手前来解决MySQLNonTransientConnectionException
- Java核心编程视频教程
protected 包内和包外的子类可以访问
JAVA里protected属性和方法的完整测试