17、下面语句正确的是:( )
A. RandomAccessFile raf=new RandomAccesssFile(“myfile.txt”,”rw”); B. RandomAccessFile raf=new RandomAccesssFile(new DataInputStream()); C. RandomAccessFile raf=new RandomAccesssFile(“myfile.txt”);
D. RandomAccessFile raf=new RandomAccesssFile(new File(“myfile.txt”));
18、在Java中,类Test的代码如下所示,假设类Test的实例化对象名为t,则选项()中的语句能正确调用Test类的方法。 Class Test {
public int change()
{
System.out.println(“No parameters”); return 0; }
public void change(double m) {
System.out.println(“parameter is:”+m); }
}
(选择一项)
a) Test.change(15.2f) b) Test.change(); c) t.change(250.5);
d) int a = t.change(13)
19、有类Copy编译后产生如下错误提示,需要修改的地方是【 】 import java.io.*;
运行时提示错误为:
Copy.java:11:可能损失精度
public class Copy {
public static void main(String[] args) throws Exception {
File inputFile = new File(\ File outputFile = new File(\
FileReader in = new FileReader(inputFile); ① FileWriter out = new FileWriter(outputFile); char c; ②
while ((c = in.read()) != -1) ③ out.write(c); ④ in.close();
out.close(); } }
A) ① B) ② C) ③ D) ④
20、在Java类中,使用以下(D)声明语句来定义公有的int型常量MAX。(选择一项) a) public int MAX=100; b) final int MAX=100;
c) public static int MAX=100;
d) Public static final int MAX=100;
21、 在Java中,已定义两个接口B和C,要定义一个实现这两个接口的类,一下 语句正确的是(C)。(选择一项)
a) interface A extends B,C b) interface A implements B,C c) class A implements B,C
d) class A implements B,implements C
22、分析如下所示的JAVA代码,其中this关键字的意思是(B) (选择一项) public class Test{
private String name; public String getName(){ return name;
}
public void setName(String name){
this.name=name; //this关键字所在的行 }
}
a) Test类
b) 是在Test类的内部指代自身的引用 c) Test类的对象引用其他Test类对象 d) 指所在的方法
23、在Java中,有如下两个类Student和Person,如果Student是Person的子类,则下列声明对象X的语句中错误的是(C) A.Person x=new Student(); B.Person x=new Person(); C.Student x=new Person(); D.Student x=new Student();
24、给定如下Java程序,这段程序编译运行后的输出结果是(D)。(选择一项) public class Test{
public static void aMethod() throws Exception{
try {
throw new Exception(); }
finally{
System.out.println(\ } }
public static void main(String[] args) {
try {
aMethod();
} catch (Exception e) {
System.out.println(\ }
System.out.println(\ } } }
a) FinallyException b) Finally
c) ExceprionFinallyFinished d) Finally
Exception Finished
25、下列创建InputStreamReader对象的方法中哪些是正确的方法? A. new InputStreamReader(new FileInputStream(“data”)); B. new InputStreamReader(new FileReader(“data”)); C. new InputStreamReader(new BufferedReader(“data”)); D. new InputStreamReader(“data”);
E. new InputStreamReader(System.in);
26、.Java中,如果类C是类B的子类,类B是类A的子类,那么下面描述正确的是(A)(选择一项)
A C不仅继承了B中的成员,同样也继承了A中的成员 B C只继承了B中的成员 C C只继承了A中的成员
D C不能继承A或B中的成员
27、分析选项中关于Java中this关键字的说法正确的是(A)(选择一项) A this关键字是在对象内部指代自身的引用 B this关键字可以在类中的任何位置使用
C this关键字和类关联,而不是和特定的对象关联 D 同一个类的不同对象公用一个this
28.在Java中,下列(AC)可以成为类Orange的构造方法(选择二项) A public Orange(){??}
B public void Orange(){?..} C public Orange(String s){??}
D public String Orange(String s ){??}
29、给定如下Java代码片段,则下列调用方法正确的是(BC)(选择二项) Public int count(int i) throws Exception {
If(i==0)
Throw new Exception(“参数不正确!”); Return20/I; }
A public void useCount() {
Count(0); }
B public void useCount() throws Exception{ Count(0); }
C public void useCount(){ Try{
Count(0); }
Catch(Exception e){} }
D public void useCount(){ Try{
Count(10); } }
30、 在JAVA的异常处理模型中,能单独和finally语句一起使用的块是(A)。 a) try b) catch
c) throw d) throws
相关推荐: