Java 笔试题含答案文档格式.docx

上传人:b****5 文档编号:20054195 上传时间:2023-01-16 格式:DOCX 页数:9 大小:17.28KB
下载 相关 举报
Java 笔试题含答案文档格式.docx_第1页
第1页 / 共9页
Java 笔试题含答案文档格式.docx_第2页
第2页 / 共9页
Java 笔试题含答案文档格式.docx_第3页
第3页 / 共9页
Java 笔试题含答案文档格式.docx_第4页
第4页 / 共9页
Java 笔试题含答案文档格式.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

Java 笔试题含答案文档格式.docx

《Java 笔试题含答案文档格式.docx》由会员分享,可在线阅读,更多相关《Java 笔试题含答案文档格式.docx(9页珍藏版)》请在冰豆网上搜索。

Java 笔试题含答案文档格式.docx

4. 

下列说法正确的有(C)

A.class中的constructor不可省略

B.constructor必须与class同名,但方法不能与class同名

C.constructor在一个对象被new时执行

D.一个class只能定义一个constructor

5.指针在任何情况下都可进行>

<

>

=,<

=,==运算?

(true)

6.下面程序的运行结果:

(B)

publicstaticvoidmain(Stringargs[]){

Threadt=newThread(){

publicvoidrun(){

pong();

}

};

t.run();

System.out.print("

ping"

staticvoidpong(){

pong"

}

Apingpong 

Bpongping 

Cpingpong和pongping都有可能 

D都不输出

7.下列属于关系型数据库的是(AB)

A.Oracle 

BMySql 

CIMS 

DMongoDB

8.GC(垃圾回收器)线程是否为守护线程?

9.volatile关键字是否能保证线程安全?

(false)

10.下列说法正确的是(AC)

ALinkedList继承自List

BAbstractSet继承自Set

CHashSet继承自AbstractSet

DWeakMap继承自HashMap

11.存在使i+1<

i的数吗?

(存在)

12.0.6332的数据类型是(B)

Afloat 

Bdouble 

CFloat 

DDouble

13.下面哪个流类属于面向字符的输入流(A 

BufferedWriter 

FileInputStream 

ObjectInputStream 

DInputStreamReader

14.Java接口的修饰符可以为(CD)

Aprivate 

Bprotected 

Cfinal 

Dabstract

15.不通过构造函数也能创建对象吗(A)

A是 

B否

16.ArrayListlist=newArrayList(20);

中的list扩充几次(A)

A0 

B1 

C2 

D3

17.下面哪些是对称加密算法(AB)

ADES 

BAES 

CDSA 

DRSA

18.新建一个流对象,下面哪个选项的代码是错误的?

A)newBufferedWriter(newFileWriter("

a.txt"

));

B)newBufferedReader(newFileInputStream("

a.dat"

C)newGZIPOutputStream(newFileOutputStream("

a.zip"

D)newObjectInputStream(newFileInputStream("

19.下面程序能正常运行吗(yes)

publicclassNULL{

publicstaticvoidhaha(){

System.out.println("

haha"

publicstaticvoidmain(String[]args){

((NULL)null).haha();

20.下面程序的运行结果是什么()

classHelloA{

publicHelloA(){

HelloA"

{System.out.println("

I'

mAclass"

static{System.out.println("

staticA"

publicclassHelloBextendsHelloA{

publicHelloB(){

HelloB"

mBclass"

staticB"

publicstaticvoidmain(String[]args){

    newHelloB();

  }

StaticA

StaticB

HelloA

I’mAclass

HelpB

I’mBClass

21. 

getCustomerInfo()方法如下,try中可以捕获三种类型的异常,如果在该方法运行中产生了一个IOException,将会输出什么结果(A)

publicvoidgetCustomerInfo(){

try{

//dosomethingthatmaycauseanException

}catch(java.io.FileNotFoundExceptionex){

FileNotFoundException!

"

}catch(java.io.IOExceptionex){

IOException!

}catch(java.lang.Exceptionex){

Exception!

BIOException!

CFileNotFoundException!

DFileNotFoundException!

22.下面代码的运行结果为:

(C)

importjava.io.*;

importjava.util.*;

publicclassfoo{

publicstaticvoidmain(String[]args){

Strings;

s="

+s);

代码得到编译,并输出“s=”

代码得到编译,并输出“s=null”

由于Strings没有初始化,代码不能编译通过

代码得到编译,但捕获到 

NullPointException异常

23. 

System.out.println("

5"

+2);

的输出结果应该是(A)。

52 

B7 

C2 

D5

24. 

指出下列程序运行的结果 

publicclassExample{

Stringstr=newString("

good"

char[]ch={'

a'

'

b'

c'

publicstaticvoidmain(Stringargs[]){

Exampleex=newExample();

ex.change(ex.str,ex.ch);

System.out.print(ex.str+"

and"

System.out.print(ex.ch);

publicvoidchange(Stringstr,charch[]){

str="

testok"

ch[0]='

g'

A、 

goodandabc

B、 

goodandgbc

C、 

testokandabc

D、 

testokandgbc 

25. 

要从文件"

file.dat"

中读出第10个字节到变量c中,下列哪个方法适合?

(AB)

FileInputStreamin=newFileInputStream("

in.skip(9);

intc=in.read();

in.skip(10);

RandomAccessFilein=newRandomAccessFile("

intc=in.readByte();

26. 

下列哪种异常是检查型异常,需要在编写程序时声明 

ANullPointerException 

BClassCastException 

CFileNotFoundException 

DIndexOutOfBoundsException 

27.下面的方法,当输入为2的时候返回值是多少?

(D)

publicstaticintgetValue(inti){

intresult=0;

switch(i){

case1:

result=result+i;

case2:

result=result+i*2;

case3:

result=result+i*3;

returnresult;

A0 

B2 

C4 

D10

Switch也需要Break

28. 

选项中哪一行代码可以替换题目中//addcodehere而不产生编译错误?

(A)

publicabstractclassMyClass{

publicintconstInt=5;

//addcodehere

publicvoidmethod(){

Apublicabstractvoidmethod(inta);

BconstInt=constInt+5;

publicintmethod();

publicabstractvoidanotherMethod(){}

29.阅读Shape和Circle两个类的定义。

在序列化一个Circle的对象circle到文件时,下面哪个字段会被保存到文件中?

( 

B)

classShape{

publicStringname;

classCircleextendsShapeimplementsSerializable{

privatefloatradius;

transientintcolor;

publicstaticStringtype="

Circle"

Aname

radius

color

type

父类为继承Serializable接口,其成员不能被序列化,静态变量和transient修饰的不能被序列化

30.下面是People和Child类的定义和构造方法,每个构造方法都输出编号。

在执行newChild("

mike"

)的时候都有哪些构造方法被顺序调用?

请选择输出结果 

(D)

classPeople{

Stringname;

publicPeople(){

System.out.print

(1);

publicPeople(Stringname){

System.out.print

(2);

this.name=name;

classChildextendsPeople{

Peoplefather;

publicChild(Stringname){

System.out.print(3);

father=newPeople(name+"

:

F"

publicChild(){

System.out.print(4);

A312 

B32 

C432 

D132

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 农学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1