您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 企业财务 > java笔试题含答案
Java笔试题(可多选)1.下面哪些是Thread类的方法(ABD)Astart()Brun()Cexit()DgetPriority()2.下面关于类的说法正确的是(A)A继承自ThrowableBSerialableC该类实现了Throwable接口D该类是一个公共类3.下面程序的运行结果是(false)Stringstr1=hello;Stringstr2=he+newString(llo);==str2);4.下列说法正确的有(C)A.class中的constructor不可省略B.constructor必须与class同名,但方法不能与class同名C.constructor在一个对象被new时执行D.一个class只能定义一个constructor5.指针在任何情况下都可进行,,=,=,==运算?(true)6.下面程序的运行结果:(B)publicstaticvoidmain(Stringargs[]){Threadt=newThread(){publicvoidrun(){pong();}};();ping);}staticvoidpong(){pong);}ApingpongBpongpingCpingpong和pongping都有可能D都不输出7.下列属于关系型数据库的是(AB)A.OracleBMySqlCIMSDMongoDB8.GC(垃圾回收器)线程是否为守护线程?(true)9.volatile关键字是否能保证线程安全?(false)10.下列说法正确的是(AC)ALinkedList继承自ListBAbstractSet继承自SetCHashSet继承自AbstractSetDWeakMap继承自HashMap11.存在使i+1i的数吗?(存在)12.的数据类型是(B)AfloatBdoubleCFloatDDouble13.下面哪个流类属于面向字符的输入流(A)ABufferedWriterBFileInputStreamCObjectInputStreamDInputStreamReader14.Java接口的修饰符可以为(CD)AprivateBprotectedCfinalDabstract15.不通过构造函数也能创建对象吗(A)A是B否16.ArrayListlist=newArrayList(20);中的list扩充几次(A)A0B1C2D317.下面哪些是对称加密算法(AB)ADESBAESCDSADRSA18.新建一个流对象,下面哪个选项的代码是错误的?(B)A)newBufferedWriter(newFileWriter());B)newBufferedReader(newFileInputStream());C)newGZIPOutputStream(newFileOutputStream());D)newObjectInputStream(newFileInputStream());19.下面程序能正常运行吗(yes)publicclassNULL{publicstaticvoidhaha(){haha);}publicstaticvoidmain(String[]args){((NULL)null).haha();}}20.下面程序的运行结果是什么()classHelloA{publicHelloA(){HelloA);}{I'mAclass);}static{staticA);}}publicclassHelloBextendsHelloA{publicHelloB(){HelloB);}{I'mBclass);}static{staticB);}publicstaticvoidmain(String[]args){newHelloB();}}StaticAStaticBHelloAI’mAclassHelpBI’mBClass21.getCustomerInfo()方法如下,try中可以捕获三种类型的异常,如果在该方法运行中产生了一个IOException,将会输出什么结果(A)publicvoidgetCustomerInfo(){try{下面代码的运行结果为:(C)import.*;import.*;publicclassfoo{publicstaticvoidmain(String[]args){Strings;s=+s);}}A代码得到编译,并输出“s=”B代码得到编译,并输出“s=null”C由于Strings没有初始化,代码不能编译通过D代码得到编译,但捕获到NullPointException异常23.5+2);的输出结果应该是(A)。A52B7C2D524.指出下列程序运行的结果(B)publicclassExample{Stringstr=newString(good);char[]ch={'a','b','c'};publicstaticvoidmain(Stringargs[]){Exampleex=newExample();,;+and);}publicvoidchange(Stringstr,charch[]){str=testok;ch[0]='g';}}A、goodandabcB、goodandgbcC、testokandabcD、testokandgbc25.要从文件中读出第10个字节到变量c中,下列哪个方法适合?(AB)AFileInputStreamin=newFileInputStream();(9);intc=();BFileInputStreamin=newFileInputStream();(10);intc=();CFileInputStreamin=newFileInputStream();intc=();DRandomAccessFilein=newRandomAccessFile();(9);intc=();26.下列哪种异常是检查型异常,需要在编写程序时声明(C)ANullPointerExceptionBClassCastExceptionCFileNotFoundExceptionDIndexOutOfBoundsException27.下面的方法,当输入为2的时候返回值是多少?(D)publicstaticintgetValue(inti){intresult=0;switch(i){case1:result=result+i;case2:result=result+i*2;case3:result=result+i*3;}returnresult;}A0B2C4D10Switch也需要Break28.选项中哪一行代码可以替换题目中阅读Shape和Circle两个类的定义。在序列化一个Circle的对象circle到文件时,下面哪个字段会被保存到文件中?(B)classShape{publicStringname;}classCircleextendsShapeimplementsSerializable{privatefloatradius;transientintcolor;publicstaticStringtype=Circle;}AnameBradiusCcolorDtype父类为继承Serializable接口,其成员不能被序列化,静态变量和transient修饰的不能被序列化30.下面是People和Child类的定义和构造方法,每个构造方法都输出编号。在执行newChild(mike)的时候都有哪些构造方法被顺序调用?请选择输出结果(D)classPeople{Stringname;publicPeople(){}publicPeople(Stringname){=name;}}classChildextendsPeople{Peoplefather;publicChild(Stringname){=name;father=newPeople(name+:F);}publicChild(){}}A312B32C432D132
本文标题:java笔试题含答案
链接地址:https://www.777doc.com/doc-7114899 .html