JAVA面试题深圳易思博doc.docx
- 文档编号:8012817
- 上传时间:2023-01-27
- 格式:DOCX
- 页数:18
- 大小:23.05KB
JAVA面试题深圳易思博doc.docx
《JAVA面试题深圳易思博doc.docx》由会员分享,可在线阅读,更多相关《JAVA面试题深圳易思博doc.docx(18页珍藏版)》请在冰豆网上搜索。
JAVA面试题深圳易思博doc
JAVA开发工程师面试题《一》
备注••请不要在试卷上打草稿!
请将答案填在答题纸上,100分钟内完成
1.根据这个类选择所有正确的内部类:
(多选)ABCclassA{
protectedinti;
A(inti){
this.i=i;
}
a.
b.
c.
d.
e.
classB{
classBextendsA{
classB{
classB{
classA{
}
}
B(){
class
}
A{
System.out.println(Hi=
}
n+i);
I
}
}
2.下列所给出的声明中,什么会写入标准输出中?
(单选)D
System.out.prindn(4|7)?
a.4b.5c.6d.7e.0
3.下列有关方法notify()(用于和wait()连接)的正确描述是:
(单选)A
a.ifthereismorethanonethreadwaitingonacondition,onlythethreadthathasbeenwaitingthelongestisnotified.
b.ifthereismorethanonethreadwaitingonacondition,thereisnowaytopredictwhichthreadwillbenotified.
c.Notify()isdefinedintheThreadclass.
d.Itisnotstrictlynecessarytoownthelockfortheobjectyouinvokenotify()for.
e.Notify()shouldonlybeinvokedfromwithinawhileloop.
4.给出下列类的定义,如没有其他实例的引用,method2()能直接访问到:
(多选)A
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个可获取的变量)
a.InputStreamReaderreader=newlnputStreamReader(stream,’’8859-8’’);
BufferedReaderbuffer=newBufferedReader(reader);
s=buffer.readLine();
b.InputStreamReaderreader=newInputStreamReader(stream);
BufferedReaderbuffer=newBufferedReader(reader);
s=buffer.readLine();
c.InputStreamReaderreader=newlnputStreamReader(myfile,"8859-8’’);
BufferedReaderbuffer=newBufferedReader(reader);
s=buffer.readLine();
d.InputStreamReaderreader=newInputStreamReader(myfile);
BufferedReaderbuffer=newBufferedReader(reader);
s=buffer.readLine();
e.FileReaderreader=newFileReader(myfile);
BufferedReaderbuffer=newBufferedReader(reader);
s=buffer.readLine();
6.哪一个对单机程序中的main()方法的声明是错误的?
(多选)DE
a.publicstaticvoidmain()
b.publicstaticvoidmain(String[]string)
c.publicstaticvoidmain(stringargs)
d.staticpublicintmain(String[]args)
e.staticvoidmain(String[]args)
7.作为文本框对象的listeners,你可以添加哪一个执行接口?
(多选)AB
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’’constructor”inthestandardoutput.
e.Thiscoderunsandwrites..null.’inthestandardoutput.
9.试分析以下两行代码:
(多选)ACD
floatf=3.2;
inti=f;
a.Thiscodewouldnotcompile.
b.Thiscodewouldcompileandiwouldbesetto3.
c.Thesecondlinewouldcompileifitwerewritteninsteadas:
inti=(byte)if;
d.Thefirstlinewouldcompileifitwerewritteninsteadas:
floatf=3.2F;
在下面init()方法给出的applet中,用户接口将出现什么情况?
(单选)C
setLayout(newBorderLayout());add(newButton(”hello’’));
}
a.Nothingwillappearintheapplet.
b.Abuttonwillappearintheappletsetinttheexactcenter.
c.Abuttonwillappearintheappletalongthetopandcenteredhorizontally.
d.Abuttonwillappearinthetopleftcorner.
10.如果你在JDK1.2下想要用值将关键字联系起来,则以下哪个类位首选?
(多选)BD
a.Dictionary
b.HashTable
c.Properties
d.HashMap
e.TreeMap
11.定义一个名为Key的无继承类正确方法是?
(单选)E
a.classKey{}
b.abstractfinalclassKey{}
c.nativeclassKey{}
d.classKey{final;
}
e.finalclassKey{}
12-下列哪一个能代表一个octalnumber?
(单选)D
a.0x12
b.320
c.032
d.(octal)2
e.12
13.当你运行Tested类时,将得到什么标准输出结果?
(单选)E
classTester2{intvar;
Tester(doublevar){this.var=(int)var;
}
Tester(intvar){this("hello");
}
Tester(Strings){this();
System.out.println(s);
}
Tester(){
System.out-printlnCgood-bye11);
}
publicstaticvoidmain(String[]args){
Testert=newTester(5);
}
}
a.nothing
b."hello"
c.5
d."hello"followingby"good-bye"
e."good-bye"followedby"hello"
14.根据提供如下代码,如果方法tryThis()发生一个NumberFormatException,将得到什么标准结果?
(单选)
try{B
tryThis();
return;
}catch(IOExceptionx1){
System.out.println(nexception1••);return;
}catch(Exceptionx2){
System.out.println(’’exception2n);return;
}finally{
System.out.printlnffinally");
}
a.Nothing
b."exception1"followedby"finally"
c."exception2"followedby”finally"
d."exception1"
e."exception2n
15.给出如下代码,如果此snippet在标准输出中显示为90,则method()调用了何种数学方法?
(单选)Cdoublea=90.7;
doubleb=method(a);
System.out.println(b);
a.abs
b.min
c.floor
d.round
e.ceil
16.如果”Ramtest”文档并不存在,而你试图编译并运行以下代码时,将会发生什么情况?
(单选)Dimportjava.io,;
classRan{
publicstaticvoidmain(String[]args)throwsIOException{
RandomAccessFileout=newRandomAccessFile(nRan.testn,”rw”);out.writeBytes("Ninotchka”);
}
}
a.ThecodedosenotcompilebecauseRandomAccessFileisnotcreatedcorrectly.
b.ThecodedosenotcompilebecauseRandomAccessFiledosenotimplementthewriteBytes()method.
c.ThecodecompilesandrunsbutthrowslOExceptionbecause"Ran.test’1doesnotyetexist.
d.Thecodecompilesandrunsbutnothingappearsintthefile"Ran.test"thatitcreates.
e.Thecodecompilesandrunsand’’Ninotchka•’appearsinthefileHRan.test,fthatitcreates.
17.当你创建一个新的线程时,如果提供一个目标对象,TargetObject是什么类型的实例才能作为合法参数传入:
Threadt=newThread(targetObject);C
a.targetObjectinstanceofThread
b.targetObjectinstandeofObject
c.targetObjectinstanceofApplet
d.targetObjectinstanceofRunnable
e.targetObjectinstanceofString
18.给出如下的代码片断,哪一个表达式为合法的java表达式,且返回值为真?
(单选):
B
Booleanb1=newBoolean(true);
Booleanb2=newBoolean(true);
a.b1==b2
b.b1.equals(b2)
c.b1&b2
d.b1|b2
e.b1&&b2
f.b1||b2
19.下列哪一个布局管理器以从左至右,然后从上到下,以每一行为中心移动的方式排列组件?
(单选)C
a.巳orderLayout
b.FlowLayout
c.GridLayout
d.CardLayout
e.Grid巳agLayout
20.下列哪一个关于垃圾收集的描述是正确的?
(多选)BC
a.Youcandirectlyfreethememoryallocatedbyanobject.
b.Youcandirectlyrunthegarbagecollectorwheneveryouwantto.
c.Thegarbagecollectorinformsyourobjectwhenitisabouttobegarbagecollected.
d.Thegarbagecollectorreclaimsanobject’smemoryassoonasitbecomesacandidateforgarbagecollection.
e.Thegarbagecollectorrunsinlow-memorysituations.
21.Giventhisinterfacedefinition:
根据该界面定义,下列哪一个类能实现该接口并且不是抽象类?
(多选)interfaceA{
intmethod1(inti);intmethod2(intj);
classB
b.classB{
c.
classB
d.
classBextends
e.classBimplements
implementsA{
intmethod1(int
implementsA{
A{
A{
intmethod1(){}
i){}
int
method1(int
int
method1(int
intmethod1(intj){}
int
intmethod2(int
i){}
i){}
intmethod2(inti){}
method2(){}
j){}
int
method2(int
int
method2(int
}
}
}
j){}
j){}
}
}
22.Examinethefollowingswitchblock根据如下的转换流,下列哪个命题是正确的?
(多选)BEcharmychar='c1;switch(mychar){
default:
case’a’:
System.out.println("an);break;casefb':
System.out.println(,fbf,);break;
}
a.Thisswitchblockisillegal,becauseonlyintegerscanbeusedintheswitchstatement.
b.Thisswitchblockisfine.
c.Thisswitchblockisillegal,becausethedefaultstatementmustcomelast.
d.Whenthiscoderuns,nothingiswrittentothestandardoutput.
e.Whenthiscoderuns,theletter”aniswrittentothestandardoutput.
23.如果你编译,运行以下类,将会出现什么情况?
(单选)C
classTest{
staticintmyArg=1;
publicstaticvoidmain(String[]args){
intmyArg;
System.out.println(myArg);
}
}
a.Thiscodecompilesanddisplays0inthestandardoutputwhenrun.
b.Thiscodecompilesanddisplays1inthestandardoutputwhenrun.
c.Thiscodedoesnotcompilebecauseyoucannotdefinealocalvariablenamedthesameasastaticvariable.
d.Thiscodedoesnotcompilebecausethelocalvariableisusedbeforeitisinitialized.
24.如果你用名为c的变量为引用组件调用addContainerListener()a^,请估计下列哪个表达式将为这个问题提出正确或错误的回答?
(单选)C
a.c==Container
b.c.equals(Class.Container)
c.cinstanceofContainer
d.cinstanceofComponent
e.cimplementsContainer
25.当下列程序运行“javaMysteryMightyMouse”命令时将得到什么结果?
(单选)A
javaMysteryMightyMouse
classMystery{
publicstaticvoidmain(String[]args){
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.ThisprogramcausesanArraylndexOutOfBoundsExceptiontobethrown.
b.Thisprogramrunsbutdoesnotwriteanythingtothestandardoutput.
c.Thisprogramwrites"MyightyMouse11tothestandardoutput.
d.Thisprogramwrites"MouseMyighty"tothestandardoutput.
26.根据提供的如下代码,请问在//A处应该补充什么代码该程序可以标准输出单词‘nmniiig’?
(单选)CclassRunTestimplementsRunnable{
publicstaticvoidmain(String[]args){
RunTestrt=newRunTest();
Threadt=newThread(rt);
"A
}
publicvoidrun(){
Systme.out.println(,frunningf,);
}
voidgo(){start。
);
}
voidstart(inti){
}
}
a.System.out.println("runningn);
b.rt.start();
C.rt.goO;
d.rt.start
(1);
27.分析下面的一行代码,选择一个正确的回答(单选A
if(5&7>0&&5|2)System.out.println("true");
a.Thislineofcodewillnotcompile.
b.Thiscodewillcompilebutnothingwillappearinthestandardoutput.
c.Thiscodewillcompileandwritetheword’.true”inthestandardoutput.
28.请选出有关在Component类中定义的paint()方法所有正确的描述:
(单选)B
a.Itisprotected.
b.IttakesaninstanceofclassGraphics.
c.Itisstatic.
d.Itisinvokedautomaticallywheneveryouminimizeandthenmaximizeacomponent,suchasawindow.
e.Thereisalsoaversionthattakesanint.
29.分析以下代码,选择所有正确的答案。
(单选)D
voidlooper(){
intx=0;one:
while(x<10){two:
System.out.println(++x);if(x>3)
breaktwo;
}
}
a.Thiscodecompiles.
b.Thiscodedoesnotcompile.
c.Thismethodwrit
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVA 试题 深圳 易思博 doc
![提示](https://static.bdocx.com/images/bang_tan.gif)