java期末考试题

2026/4/28 15:06:56

D、interface B { void print();}

M、下面哪个函数是public?void? aMethod(){...}的重载函数?( D )

A、void? aMethod(?){...} B、public?int? aMethod(){...} C、public?void? aMethod ( ){...} D、public?int? aMethod?(?int?m){...}

N、A派生出子类B?,B派生出子类C,并且在Java源代码中有如下声明:

1.A a0=new A();

2.A? a1 =new B();

3.A a2=new C();

问以下哪个说法是正确的??( ) A、只有第1行能通过编译

?

B、第1、2行能通过编译,但第3行编译出错 C、第1、2、3行能通过编译,但第2、3行运行时出错 D、第1行、第2行和第3行的声明都是正确的?

O、假设A类有如下定义,设a是A类的一个实例,下列语句调用哪个是错误的?class A

{ int i;

D )(

static String s;

void method1() { }

static void method2() { }

}

P、有如下代码段:

1)

2) { if(unsafe()){//do something…}

3) else if(safe()){//do the other…}

4) }

其中,方法unsafe() 将抛出IOException, 请问可将以下哪项填入第1行?(A、public IOException methodName()

B、public void methodName()

C、public void methodName() throw IOException D、public void methodName() throws IOException

一、 程序阅读

1、写出以下程序的运行结果。

public class EqualOrNot

D )

{ public static void main(String[] args)

{ B b1=new B(5);

B b2=new B(5);

.equals(b2));

}

}

class B

{ int x;

B( int y){ x=y; }

}

2、写出以下程序的运行结果。

import java.io.*;

public class TestString

{ public static void main(String args[ ])

{ StringC s = new StringC (\

}

class StringC {

String s1;

String s2;

StringC( String str1 , String str2 )

{ s1 = str1; s2 = str2; }

public String toString( )

{ return s1+s2;}

}

3、写出以下程序的功能。

import java.io.*;

public class C {

public static void main(String[] args) throws IOException {

File inputFile = new File(“a.txt\

File outputFile = new File(“b.txt\

FileReader in = new FileReader(inputFile);

FileWriter out = new FileWriter(outputFile);

int c;

while ((c = in.read() ) != -1) out.write(c);


java期末考试题.doc 将本文的Word文档下载到电脑
搜索更多关于: java期末考试题 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219