Java工程师全英文面试题.docx
《Java工程师全英文面试题.docx》由会员分享,可在线阅读,更多相关《Java工程师全英文面试题.docx(8页珍藏版)》请在冰点文库上搜索。
Java工程师全英文面试题
Java软件工程师面试题
Circleoneormoreoptionswhicharecorrect.
1.WhywouldsomeonewanttouseJavaScriptonaWebpage?
(5scores)
A.ToreacttoeventsthatoccurwithWebpageuse
B.ToreadandwriteHTML
C.TovalidatedatainaWebform
D.TopassdatatoaJavaappletprogram
E.TorunaclockortimerinaWebpage
2.EvaluatethefollowingStringmethodusesbywritingthevalueofsaftertheevaluation(5scores)(writeonevalueonthelinetotherightofeachevaluation)
varstr="MixandMatch"
A.s=str.indexOf("x")__2
B.s=str.indexOf("g")___-1
C.s=str.indexOf("M")___0
D.s=str.lastIndexOf("a")___9
E.s=str.indexOf("and")___4
3.HowcansomeoneproperlyopenasecondWebbrowserwindowwithaJavaScriptstatement?
(5scores)
A.document.openWin("")
B.openWindow("")
C.window.open(“”)
D.document.open("")
E.document.location("")
4.GiventhefollowingvalidHTMLform,howwouldyouassignthevaluetypedintotheowner
controltoavariablessninaJavaScriptstatement?
(5scores)
A.ssn=window.SSN.owner.value;
B.ssn=document.SSN.owner.value;
C.ssn=document.SSN.input.value;
D.ssn=document.form.input.value;
E.ssn=window.owner.value;
5.AfteraJavaScriptfunctionrunsthefollowingtwolinesofcode,whatvaluedoesthevariablexcontain?
(5scores)
arr=newArray(5);
x=Math.random()/arr.length;
A.afloatingpointnumberbetween0.0and0.2
B.afloatingpointnumberbetween0.0and0.25
C.afloatingpointnumberbetween0.0and1.0
D.afloatingpointnumberbetween0.0and5.0
E.xwouldnotbeassignedduetooneormoreerrorsinthecode
6.WhatisthevalueofvariablexafterthefollowingblockofJavaScriptcodeisrun?
(5scores)
x=0;
y=2;
while(y>0.5||y<0.0){
x=x+1;
y=y/x-y;
}
A.0
B.1
C.morethan1
D.undeterminedsincethecodedividesbyzero
E.lessthan1
7.Whatwillhappenwhenyouattempttocompileandrunthiscode?
(5scores)
abstractclassBase{
abstractpublicvoidmyfunc();
publicvoidanother(){
System.out.println("Anothermethod");
}
}
publicclassAbsextendsBase{
publicstaticvoidmain(Stringargv[]){
Absa=newAbs();
a.amethod();
}
publicvoidmyfunc(){
System.out.println("MyFunc");
}
publicvoidamethod(){
myfunc();
}
}
AThecodewillcompileandrun,printingoutthewords"MyFunc"
BThecompilerwillcomplainthattheBaseclasshasnonabstractmethods
CThecodewillcompilebutcomplainatruntimethattheBaseclasshasnonabstractmethods
DThecompilerwillcomplainthatthemethodmyfuncinthebaseclasshasnobody,nobodyatalltoloooveit
8.WhichmostcloselymatchesadescriptionofaJavaMap?
(5scores)
A.Avectorofarraysfora2Dgeographicrepresentation
B.Aclassforcontaininguniquearrayelements
C.Aclassforcontaininguniquevectorelements
D.Aninterfacethatensuresthatimplementingclassescannotcontainduplicatekeys
9.Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?
(5scores)
publicclassStrEq{
publicstaticvoidmain(Stringargv[]){
StrEqs=newStrEq();
}
privateStrEq(){
Strings="Marcus";
Strings2=newString("Marcus");
if(s==s2){
System.out.println("wehaveamatch");
}else{
System.out.println("Notequal");
}
}
}
A.Compiletimeerrorcausedbyprivateconstructor
B.Outputof"wehaveamatch"
C.Outputof"Notequal"
D.Compiletimeerrorbyattemptingtocomparestringsusing==
10.Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?
(5scores)
importjava.io.*;
classBase{
publicvoidamethod()throwsFileNotFoundException{}
}
publicclassExcepDemoextendsBase{
publicstaticvoidmain(Stringargv[]){
ExcepDemoe=newExcepDemo();
}
publicvoidamethod(){}
protectedExcepDemo(){
try{
DataInputStreamdin=newDataInputStream(System.in);
System.out.println("Pausing");
din.readByte();
System.out.println("Continuing");
this.amethod();
}catch(IOExceptionioe){
}
}
}
A.Compiletimeerrorcausedbyprotectedconstructor
B.CompiletimeerrorcausedbyamethodnotdeclaringException
C.RuntimeerrorcausedbyamethodnotdeclaringException
D.Compileandrunwithoutputof"Pausing"and"Continuing"afterakeyishit
11.Whatwillhappenwhenyouattempttocompileandrunthisprogram?
(5scores)publicclassOuter{
publicStringname="Outer";
publicstaticvoidmain(Stringargv[]){
Inneri=newInner();
i.showName();
}//Endofmain
privateclassInner{
Stringname=newString("Inner");
voidshowName(){
System.out.println(name);
}
}//EndofInnerclass
}
A.Compileandrunwithoutputof"Outer"
B.Compileandrunwithoutputof"Inner"
C.CompiletimeerrorbecauseInnerisdeclaredasprivate
D.CompiletimeerrorbecauseofthelinecreatingtheinstanceofInner
12.Whatwillbeoutputbythefollowingline?
(5scores)
System.out.println(Math.floor(-2.1));
A.-2
B.2.0
C.-3
D.-3.0
13.Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?
(5scores)
intOutput=10;
booleanb1=false;
if((b1==true)&&((Output+=10)==20)){
System.out.println("Weareequal"+Output);
}else{
System.out.println("Notequal!
"+Output);
}
A.Compileerror,attemptingtopeformbinarycomparisononlogicaldatatype
B.Compilationandoutputof"Weareequal10"
C.Compilationandoutputof"Notequal!
20"
D.Compilationandoutputof"Notequal!
10"
14.Giventhefollowingvariables
charc='c';
inti=10;
doubled=10;
longl=1;
Strings="Hello";
Whichofthefollowingwillcompilewithouterror?
(5scores)
A.c=c+i;
B.s+=i;
C.i+=s;
D.c+=s;
15.Giventhefollowingclassdefinition,whichofthefollowingstatementswouldbelegalafterthecomment//Here?
(5scores)
classInOut{
Strings=newString("Between");
publicvoidamethod(finalintiArgs){
intiam;
classBicycle{
publicvoidsayHello(){
//Here
}
}//Endofbicycleclass
}//Endofamethod
publicvoidanother(){