考点~~~

venket 2004-10-21 08:22:40

You want a class to have access to members of another class in the same package. Which is the most
restrictive access modifier that will accomplish that will accomplish this objective?
A. Public
B. Private
C. Protected
D. Transient
E. No access modifier is required.
Answer: E


Which two statements are true regarding the creation of a default constructor? (Choose Two)
A. The default constructor initializes method variables.
B. The default constructor invokes the no-parameter constructor of the superclass.
C. The default constructor initializes the instance variables declared in the class.
D. If a class lacks a no-parameter constructor,, but has other constructors, the compiler creates a
default constructor.
E. The compiler creates a default constructor only when there are no other constructors for the class.
Answer: C, E



Given:
1. public class Foo implements Runnable (
2. public void run (Thread t) {
3. system.out.printIn(“Running.”);
4. }
5. public static void main (String[] args) {
6. new thread (new Foo()).start();
7. )
8. )
What is the result?
A. An exception is thrown.
B. The program exists without printing anything.


A. Member data have no access modifiers.
B. Member data can be modified directly.
C. The access modifier for methods is protected.
D. The access modifier to member data is private.
E. Methods provide for access and modification of data.


A. An anonymous inner class can be declared inside of a method
B. An anonymous inner class constructor can take arguments in some situation.
C. An anonymous inner class that is a direct subclass that is a direct subclass of Object can implement
multiple interfaces.
D. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous
inner class that is an immediate subclass of Super that implements a single interface.
E. Event if a class Super does not implement any interfaces, it is still possible to define an anonymous
inner class that is an immediate subclass of Super that implements multiple interfaces.
高手请帮帮忙,帮我解释一下答案的理由~~~~~~~~~~~~~~~~~~
...全文
132 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
venket 2004-11-01
  • 打赏
  • 举报
回复
你们能不能作个详细的解释 呢?
crimson1128 2004-10-24
  • 打赏
  • 举报
回复
劳驾人家问的是most restrictive,当然是不会是public了
详见sl-275 p6-8
venket 2004-10-22
  • 打赏
  • 举报
回复
那么public呢?
他不是可以访问吗?
黑马 2004-10-21
  • 打赏
  • 举报
回复
1、PRIVATE可以访问同一个包里任何类的方法和变量
2、default constructor 可以初始化实例变量,如果类里没有任何构造函数则自动创建一个构造函数,如果有则不创建
3、A,run()方法不带任何参数
4、A
5、AD
黑马 2004-10-21
  • 打赏
  • 举报
回复
第一个说错了,不好意思

是default不是private
tom2005 2004-10-21
  • 打赏
  • 举报
回复
1、PRIVATE可以访问同一个包里任何类的方法和变量

PRIVATE不可以吧
3 A
没有实现 Runnable接口

50,530

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧