Java 笔试题.docx

上传人:b****5 文档编号:8520717 上传时间:2023-01-31 格式:DOCX 页数:9 大小:17.03KB
下载 相关 举报
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

Java笔试题

班级:

_______________学号:

______________姓名:

___________

Java笔试题

(可多选)

1.下面哪些是Thread类的方法()

Astart()   Brun()   Cexit()   DgetPriority()

 

2.下面关于java.lang.Exception类的说法正确的是()

A继承自Throwable   

BSerialable   

C该类实现了Throwable接口

D该类是一个公共类

 

3.下面程序的运行结果是()

Stringstr1="hello";

Stringstr2="he"+newString("llo");

System.err.println(str1==str2);

 

4. 下列说法正确的有()

A.class中的constructor不可省略

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

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

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

 

5.指针在任何情况下都可进行>,<,>=,<=,==运算?

()

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

()

publicstaticvoidmain(Stringargs[]){

Threadt=newThread(){

publicvoidrun(){

pong();

}

};

t.run();

System.out.print("ping");

}

staticvoidpong(){

System.out.print("pong");

}

Apingpong    

Bpongping   

Cpingpong和pongping都有可能   

D都不输出

 

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

A.Oracle  BMySql  CIMS  DMongoDB

 

8.GC线程是否为守护线程?

()

 

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

()

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

ALinkedList继承自List

BAbstractSet继承自Set

CHashSet继承自AbstractSet

DWeakMap继承自HashMap

 

11.存在使i+1

()

 

12.0.6332的数据类型是()

Afloat  Bdouble  CFloat   DDouble

 

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

A  BufferedWriter 

B  FileInputStream  

C  ObjectInputStream  

DInputStreamReader

 

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

Aprivate  Bprotected   Cfinal   Dabstract

 

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

A是  B否

 

16.ArrayListlist=newArrayList(20);中的list扩充几次()

A0  B1  C2   D3

 

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

ADES BAES CDSA DRSA

 

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

()

A)newBufferedWriter(newFileWriter("a.txt"));

B)newBufferedReader(newFileInputStream("a.dat"));

C)newGZIPOutputStream(newFileOutputStream("a.zip"));

D)newObjectInputStream(newFileInputStream("a.dat"));

 

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

publicclassNULL{

publicstaticvoidhaha(){

System.out.println("haha");

}

publicstaticvoidmain(String[]args){

((NULL)null).haha();

}

}

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

classHelloA{

publicHelloA(){

System.out.println("HelloA");

}

{System.out.println("I'mAclass");}

static{System.out.println("staticA");}

}

publicclassHelloBextendsHelloA{

publicHelloB(){

System.out.println("HelloB");

}

{System.out.println("I'mBclass");}

static{System.out.println("staticB");}

publicstaticvoidmain(String[]args){

    newHelloB();

  }

}

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

publicvoidgetCustomerInfo(){

try{

//dosomethingthatmaycauseanException

}catch(java.io.FileNotFoundExceptionex){

System.out.print("FileNotFoundException!

");

}catch(java.io.IOExceptionex){

System.out.print("IOException!

");

}catch(java.lang.Exceptionex){

System.out.print("Exception!

");

}

}

A IOException!

BIOException!

Exception!

CFileNotFoundException!

IOException!

DFileNotFoundException!

IOException!

Exception!

 

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

()

importjava.io.*;

importjava.util.*;

publicclassfoo{

publicstaticvoidmain(String[]args){

Strings;

System.out.println("s="+s);

}

}

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

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

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

D 代码得到编译,但捕获到 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中,下列哪个方法适合?

 ()

A FileInputStreamin=newFileInputStream("file.dat");in.skip(9);intc=in.read();

B FileInputStreamin=newFileInputStream("file.dat");in.skip(10);intc=in.read();

C FileInputStreamin=newFileInputStream("file.dat");intc=in.read();

D RandomAccessFilein=newRandomAccessFile("file.dat");in.skip(9);intc=in.readByte();

 

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

ANullPointerException       

BClassCastException     

CFileNotFoundException      

DIndexOutOfBoundsException 

 

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

()

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

 

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

()

publicabstractclassMyClass{

publicintconstInt=5;

//addcodehere

publicvoidmethod(){

}

}

Apublicabstractvoidmethod(inta);

BconstInt=constInt+5;

C publicintmethod();

D publicabstractvoidanotherMethod(){}

 

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

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

 ( )

classShape{

publicStringname;

}

classCircleextendsShapeimplementsSerializable{

privatefloatradius;

transientintcolor;

publicstaticStringtype="Circle";

}

Aname

B radius

C color

D type

 

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

在执行newChild("mike")的时候都有哪些构造方法被顺序调用?

请选择输出结果 ()

classPeople{

Stringname;

publicPeople(){

System.out.print

(1);

}

publicPeople(Stringname){

System.out.print

(2);

this.name=name;

}

}

classChildextendsPeople{

Peoplefather;

publicChild(Stringname){

System.out.print(3);

this.name=name;

father=newPeople(name+":

F");

}

publicChild(){

System.out.print(4);

}

}

A312             B32              C432             D132

 

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

当前位置:首页 > 初中教育

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

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