JAVA面试题二文档格式.docx

上传人:b****4 文档编号:6623099 上传时间:2023-05-07 格式:DOCX 页数:23 大小:23.64KB
下载 相关 举报
JAVA面试题二文档格式.docx_第1页
第1页 / 共23页
JAVA面试题二文档格式.docx_第2页
第2页 / 共23页
JAVA面试题二文档格式.docx_第3页
第3页 / 共23页
JAVA面试题二文档格式.docx_第4页
第4页 / 共23页
JAVA面试题二文档格式.docx_第5页
第5页 / 共23页
JAVA面试题二文档格式.docx_第6页
第6页 / 共23页
JAVA面试题二文档格式.docx_第7页
第7页 / 共23页
JAVA面试题二文档格式.docx_第8页
第8页 / 共23页
JAVA面试题二文档格式.docx_第9页
第9页 / 共23页
JAVA面试题二文档格式.docx_第10页
第10页 / 共23页
JAVA面试题二文档格式.docx_第11页
第11页 / 共23页
JAVA面试题二文档格式.docx_第12页
第12页 / 共23页
JAVA面试题二文档格式.docx_第13页
第13页 / 共23页
JAVA面试题二文档格式.docx_第14页
第14页 / 共23页
JAVA面试题二文档格式.docx_第15页
第15页 / 共23页
JAVA面试题二文档格式.docx_第16页
第16页 / 共23页
JAVA面试题二文档格式.docx_第17页
第17页 / 共23页
JAVA面试题二文档格式.docx_第18页
第18页 / 共23页
JAVA面试题二文档格式.docx_第19页
第19页 / 共23页
JAVA面试题二文档格式.docx_第20页
第20页 / 共23页
亲,该文档总共23页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

JAVA面试题二文档格式.docx

《JAVA面试题二文档格式.docx》由会员分享,可在线阅读,更多相关《JAVA面试题二文档格式.docx(23页珍藏版)》请在冰点文库上搜索。

JAVA面试题二文档格式.docx

3.下列有关方法notify()(用于和wait()连接)的正确描述是:

(单选c)

a.ifthereismorethanonethreadwaitingonacondition,onlythethreadthathasbeenwaitingthelongestisnotified.

b.ifthereismorethanonethreadwaitingonacondition,thereisnowaytopredictwhichthreadwillbenotified.

c.Notify()isdefinedintheThreadclass.

d.Itisnotstrictlynecessarytoownthelockfortheobjectyouinvokenotify()for.

e.Notify()shouldonlybeinvokedfromwithinawhileloop.

4.给出下列类的定义,如没有其他实例的引用,method2()能直接访问到:

(多选abc)

classA{

publicintx;

privateinty;

classB{

protectedvoidmethod1(){

}

classC{

privatevoidmethod2(){

}

classdextendsA{

publicfloatz;

a.ThevariablexdefinedinA

b.ThevariableydefinedinA

c.method()definedinB

d.ThevariablezdefinedinD

5.你有一个用ISO8859-8定义的8位字符串文档,当你要在文本域中写一个显示该文档的应用,而局部编码已经设置成ISO8859-8时,你如何写一段代码来读取该文档的第一行?

(你有3个可获取的变量c)

a.InputStreamReaderreader=newInputStreamReader(stream,"

8859-8"

);

BufferedReaderbuffer=newBufferedReader(reader);

s=buffer.readLine();

b.InputStreamReaderreader=newInputStreamReader(stream);

c.InputStreamReaderreader=newInputStreamReader(myfile,"

d.InputStreamReaderreader=newInputStreamReader(myfile);

e.FileReaderreader=newFileReader(myfile);

6.哪一个对单机程序中的main()方法的声明是错误的?

(多选cd)

a.publicstaticvoidmain()

b.publicstaticvoidmain(String[]string)

c.publicstaticvoidmain(stringargs)

d.staticpublicintmain(String[]args)

e.staticvoidmain(String[]args)

7.作为文本框对象的listeners,你可以添加哪一个执行接口?

(多选acd)

a.ActionListener

b.FocusListener

c.MouseMotionListener

d.WindowListener

e.ContainerListener

8.当你试着编译和运行下面的程序时,结果怎样?

(单选e)

classMyTest{

Strings;

publicstaticvoidmain(String[]args){

MyTestm=newMyTest();

m.go();

voidMyTest(){

s="

constructor"

;

voidgo(){

System.out.println(s);

a.Thiscodewillnotcompile.

b.Thiscodecompilesbutthrowsanexceptionatruntime.

c.Thiscoderunsbutnothingappearsinthestandardoutput.

d.Thiscoderunsand"

inthestandardoutput.

e.Thiscoderunsandwrites"

null"

9.试分析以下两行代码:

(多选ad)

floatf=3.2;

inti=f;

a.Thiscodewouldnotcompile.

b.Thiscodewouldcompileandiwouldbesetto3.

c.Thesecondlinewouldcompileifitwerewritteninsteadas:

inti=(byte)if;

d.Thefirstlinewouldcompileifitwerewritteninsteadas:

floatf=3.2F;

10.在下面init()方法给出的applet中,用户接口将出现什么情况?

publicvoidinit(){

setLayout(newBorderLayout());

add(newButton("

hello"

));

a.Nothingwillappearintheapplet.

b.Abuttonwillappearintheappletsetinttheexactcenter.

c.Abuttonwillappearintheappletalongthetopandcenteredhorizontally.

d.Abuttonwillappearinthetopleftcorner.

11.如果你在JDK1.2下想要用值将关键字联系起来,则以下哪个类位首选?

(多选be)

a.Dictionary

b.HashTable

c.Properties

d.HashMap

e.TreeMap

12.定义一个名为Key的无继承类正确方法是?

a.classKey{}

b.abstractfinalclassKey{}

c.nativeclassKey{}

d.classKey{

final;

e.finalclassKey{}

13.下列哪一个能代表一个octalnumber?

a.0x12

b.320

c.032

d.(octal)2

e.12

14.当你运行Tester2类时,将得到什么标准输出结果?

classTester2{

intvar;

Tester(doublevar){

this.var=(int)var;

Tester(intvar){

this("

Tester(Strings){

this();

Tester(){

System.out.println("

good-bye"

Testert=newTester(5);

a.nothing

b."

c.5

d."

followingby"

e."

followedby"

15.根据提供如下代码,如果方法tryThis()发生一个NumberFormatException,将得到什么标准结果?

try{

tryThis();

return;

}catch(IOExceptionx1){

exception1"

}catch(Exceptionx2){

exception2"

}finally{

finally"

a.Nothing

c."

16.给出如下代码,如果此snippet在标准输出中显示为90,则method()调用了何种数学方法?

doublea=90.7;

doubleb=method(a);

System.out.println(b);

a.abs

b.min

c.floor

d.round

e.ceil

17.如果"

Ran.test"

文档并不存在,而你试图编译并运行以下代码时,将会发生什么情况?

importjava.io.*;

classRan{

publicstaticvoidmain(String[]args)throwsIOException{

RandomAccessFileout=newRandomAccessFile("

"

rw"

out.writeBytes("

Ninotchka"

a.ThecodedosenotcompilebecauseRandomAccessFileisnotcreatedcorrectly.

b.ThecodedosenotcompilebecauseRandomAccessFiledosenotimplementthewriteBytes()method.

c.ThecodecompilesandrunsbutthrowsIOExceptionbecause"

doesnotyetexist.

d.Thecodecompilesandrunsbutnothingappearsintthefile"

thatitcreates.

e.Thecodecompilesandrunsand"

appearsinthefile"

18.当你创建一个新的线程时,如果提供一个目标对象,TargetObject是什么类型的实例才能作为合法参数传入:

(a)

Threadt=newThread(targetObject);

a.targetObjectinstanceofThread

b.targetObjectinstandeofObject

c.targetObjectinstanceofApplet

d.targetObjectinstanceofRunnable

e.targetObjectinstanceofString

19.给出如下的代码片断,哪一个表达式为合法的Java表达式,且返回值为真?

(单选b):

Booleanb1=newBoolean(true);

Booleanb2=newBoolean(true);

a.b1==b2

b.b1.equals(b2)

c.b1&

b2

d.b1|b2

e.b1&

&

f.b1||b2

20.下列哪一个布局管理器以从左至右,然后从上到下,以每一行为中心移动的方式排列组件?

(单选b)

a.BorderLayout

b.FlowLayout

c.GridLayout

d.CardLayout

e.GridBagLayout

21.下列哪一个关于垃圾收集的描述是正确的?

(多选de)

a.Youcandirectlyfreethememoryallocatedbyanobject.

b.Youcandirectlyrunthegarbagecollectorwheneveryouwantto.

c.Thegarbagecollectorinformsyourobjectwhenitisabouttobegarbagecollected.

d.Thegarbagecollectorreclaimsanobject'

smemoryassoonasitbecomesacandidateforgarbagecollection.

e.Thegarbagecollectorrunsinlow-memorysituations.

22.Giventhisinterfacedefinition:

根据该界面定义,下列哪一个类能实现该接口并且不是抽象类?

(多选ce)

interfaceA{

intmethod1(inti);

intmethod2(intj);

classB

implementsA{

intmethod1(){}

intmethod2(){}

b.classB{

intmethod1(inti){}

intmethod2(intj){}

c.classBimplementsA{

d.classBextendsA{

e.classBimplementsA{

intmethod1(intj){}

intmethod2(inti){}

23.Examinethefollowingswitchblock根据如下的转换流,下列哪个命题是正确的?

charmychar='

c'

switch(mychar){

default:

case'

a'

:

a"

break;

b'

b"

a.Thisswitchblockisillegal,becauseonlyintegerscanbeusedintheswitchstatement.

b.Thisswitchblockisfine.

c.Thisswitchblockisillegal,becausethedefaultstatementmustcomelast.

d.Whenthiscoderuns,nothingiswrittentothestandardoutput.

e.Whenthiscoderuns,theletter"

iswrittentothestandardoutput.

24.如果你编译,运行以下类,将会出现什么情况?

classTest{

staticintmyArg=1;

intmyArg;

System.out.println(myArg);

a.Thiscodecompilesanddisplays0inthestandardoutputwhenrun.

b.Thiscodecompilesanddisplays1inthestandardoutputwhenrun.

c.Thiscodedoesnotcompilebecauseyoucannotdefinealocalvariablenamedthesameasastaticvariable.

d.Thiscodedoesnotcompilebecausethelocalvariableisusedbeforeitisinitialized.

25.如果你用名为c的变量为引用组件调用addContainerListener()函数,请估计下列哪个表达式将为这个问题提出正确或错误的回答?

a.c==Container

b.c.equals(Class.Container)

c.cinstanceofContainer

d.cinstanceofComponent

e.cimplementsContainer

26.当下列程序运行“javaMysteryMightyMouse”命令时将得到什么结果?

(单选b)

javaMysteryMightyMouse

classMystery{

Changerc=newChanger();

c.method(args);

System.out.println(args[0]+"

"

+args[1]);

staticclassChanger{

voidmethod(String[]s){

Stringtemp=s[0];

s[0]=s[1];

s[1]=temp;

a.ThisprogramcausesanArrayIndexOutOfBoundsExceptiontobethrown.

b.Thisprogramrunsbutdoesnotwriteanythingtothestandardoutput.

c.Thisprogramwrites"

MyightyMouse"

tothestandardoutput.

d.Thisprogramwrites"

MouseMyighty"

tothestandardoutput.

27.根据提供的如下代码,请问在//A处应该补充什么代码该程序可以标准输出单词‘running’?

(单选a)

classRunTestimplementsRunnable{

RunTestrt=newRunTest();

Threadt=newThread(rt);

//A

publicvoidrun(){

Systme.out.println("

running"

start

(1);

voidstart(inti){

a.System.out.println("

b.rt.start();

c.rt.go();

d.rt.start

(1);

28.分析下面的一行代码,选择一个正确的回答(单选c)

if(5&

7>

0&

5|2)System.out.println("

true"

a.Thislineofcodewillnotcompile.

b.Thiscodewillcompilebutnothingwillappearinthestandardoutput.

c.Thiscodewillcompileandwritetheword"

29.请选出有关在Component类中定义的paint()方法所有正确的描述:

a.Itisprotected.

b.IttakesaninstanceofclassGraphics.

c.Itisstatic.

d.Itisinvokedautomaticallywheneveryouminimizeandthenma

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

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2