- 19
- 0
- 约3.66万字
- 约 69页
- 2020-03-09 发布于江西
- 举报
Comment [S1]: 在
Comment [S1]: 在接口中,所有的数 据域都是 public static final 的,所有 的方法都是 public abstract 的
因为 A 中的 m()是 final 的
public void m() {
Comment [S3]: 声明异常的关键字是 throws,抛出异常的关键字是 throw
Java 程序设计习题
单项选择题(80)
1. 接口中的成员变量被隐含地声明为
public static final
public final
public static
public abstract
2. 处理按钮点击事件的类需要实现哪个接口
FocusListener
ActionListener
WindowListener
ItemListener
Comment [S2]: 不能覆盖 A 中的 m(),
3.
已知:
class A {
public final void m() {
System.out.println(“A.m”);
}
}
public class B extends A {
System.out.println(“B.m”);
super.m();
}
public static void main(String [] args) { new B().m();
}
}
那么结果为?
A.m
B.m
B.m
A.m
(D)编译错误
4. 抛出异常,使用关键字
try
throw
finally
catch
用父类的
用父类的无参构造方法,但是父类 由于显示地定义了含参构造方法, 所以他没有无参构造方法,导致编 译错误。
public Derived (String s) {
Comment [S5]: “if”的”i”大写了不知 道算不算,还有就是括号不匹配
5. 已知:
class Base {
public Base(String s) {
System.out.print(“B”);
}
}
public class Derived extends Base {
System.out.print(“D”);
}
public static void main(String [] args) { new Derived (“C”);
}
}
那么结果为?
BD
DB
C
编译错误
6. Java 中 char 类型的数据长度为
8 位
16 位
32 位
64 位
7. Java 编译输出文件的后缀是
exe
java
class
obj
Comment [S4]: 默认第一句为 super();调
8.
已知:
class C {
public static void main(String[] args) { boolean a = true;
boolean b = false;
boolean c = true;
if((a b) | (b c) c) System.out.print(“A”);
If((a = false) | (a c) ) | (a | b)) System.out.print(“B”);
}
}
Comment [S6]: 100.0
Comment [S6]: 100.0 是 double 型的, 不能转换为 float
Comment [S7]: Java 很恶心,居然不 支持 String 的下标访问
Comment [S8]: 书 P185 7.11
Comment [S9]: 书 P254 9.11
A
B
AB
编译错误
9. 下面哪个表达式是错误的
int i = 100;
float f = 100.0;
Object o = “Hello world”;
char c = ‘\u1234’;
10. 引用类型的数据字段的缺省值为
0.0
0
null
false
11. 下面哪个表达式可以获取字符串 s 的最后一个字符
s.length()
s[s.length() - 1]
s.charAt(s.length() - 1)
charAt(s, length(s))
12. 数据字段的作用域是
所在的语句块
所在的类
所在的方法
所在的构造函数
13.
如果类中的成员只能被子类或同一包中的类访问,那么声明该成员时应使用下面哪个
修饰符
private
package
protected
public
14. import 语句的作用是
导入包中成员
创建包
既可导入包成员,也可创建包
访问控制
15. 已知:
class C {
Comment [S10]: 如果操作数之
Comment [S10]: 如果操作数之一不 是字符串,非字符串值先转换为字 符串
原创力文档

文档评论(0)