当前位置: 技术问答>java相关
内部类问题??????,,,,,,,,,,,
来源: 互联网 发布时间:2015-03-14
本文导语: package foo; public class Outer{ public static class Inner{} } which statement is true? a. An instance of the Inner class can be constructed with "new Outer.Inner()" b. An instance of the Inner class cannot be constructed outside of package foo c. ...
package foo;
public class Outer{
public static class Inner{}
}
which statement is true?
a. An instance of the Inner class can be constructed with "new Outer.Inner()"
b. An instance of the Inner class cannot be constructed outside of package foo
c. An instance of the Inner class can only be constructed from within the outer class
d. From within the package bar, an instance of the inner class can be constructed with "new inner()"
我认为选a
大家怎么看??
public class Outer{
public static class Inner{}
}
which statement is true?
a. An instance of the Inner class can be constructed with "new Outer.Inner()"
b. An instance of the Inner class cannot be constructed outside of package foo
c. An instance of the Inner class can only be constructed from within the outer class
d. From within the package bar, an instance of the inner class can be constructed with "new inner()"
我认为选a
大家怎么看??
|
正确,是a ,因为内部类为静态,就象静态变态一样,可以用Outer.var访问,因此,
在包外也可以看得见Outer中的内部类,而不用实例化外部类。因此
new Outer.inner();
在包外也可以看得见Outer中的内部类,而不用实例化外部类。因此
new Outer.inner();
|
同意
|
a
tij里面讲过!
tij里面讲过!
|
a
|
a.
因为静态内部类可以当成顶级类对待。
因为静态内部类可以当成顶级类对待。
|
a
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。