java选择题100题Word文档下载推荐.docx
- 文档编号:17842845
- 上传时间:2022-12-11
- 格式:DOCX
- 页数:12
- 大小:19.36KB
java选择题100题Word文档下载推荐.docx
《java选择题100题Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《java选择题100题Word文档下载推荐.docx(12页珍藏版)》请在冰豆网上搜索。
TheStringNo.3is"
+s3);
TheStringNo.4is"
+s4);
TheStringNo.5is"
+s5);
}
ATheStringNo.1is
TheStringNo.2isString2
TheStringNo.3isastring
TheStringNo.4isstring
TheStringNo.5isastring
BTheStringNo.1is
TheStringNo.4istring
CTheStringNo.1is
TheStringNo.4isstrin
D以上都不对
4、下面语句段的输出结果是什么?
inti=9;
switch(i){
default:
default"
case0:
zero"
break;
case1:
one"
case2:
two"
}
Adefault
Bdefault,zero
Cerrordefaultclausenotdefined
Dnooutputdisplayed
二、多项选择
1、下面哪些语句能够正确地生成5个空字符串?
AStringa[]=newString[5];
for(inti=0;
i<
5;
a[++]="
"
BStringa[]={"
"
CStringa[5];
DString[5]a;
EString[]a=newString[5];
for(inti=0;
a[i++]=null);
2、下面哪些选项将是下述程序的输出?
publicclassOuter{
Outer:
i<
3;
i++)
inner:
for(intj=0;
j<
j++){
if(j>
1)break;
System.out.println(j+"
and"
+i);
A0and0
B0and1
C0and2
D0and3
E2and2
F2and1
G2and0
3、下面哪个语句正确地声明一个整型的二维数组?
Ainta[][]=newint[][];
Binta[10][10]=newint[][];
Cinta[][]=newint[10][10];
Dint[][]a=newint[10][10];
Eint[]a[]=newint[10][10];
JAVA笔试题选择题
1下面哪个是正确的类声明?
假设每一段文本都做为一个名称为Fred.java的文件的全部内容?
a).
publicclassFred{
publicintx=0;
publicFred(intx){
this.x=x;
}
b).
publicclassfred{
this.x=x;
c).
publicclassFredextendsMyBaseClass,MyOtherBaseClass{
publicFred(intxval){
x=xval;
d).
protectedclassFred{
privateintx=0;
privateFred(intxval){
A.a)
B.b)
C.c)
D.d)
2.在类设计中,类的成员变量要求仅仅能够被同一package下的类访问,请问应该使用下列哪个修辞词
A.protected
B.public
C.private
D.不需要任何修辞词
3.下面那个是Runable接口的方法?
A.run
B.start
C.yield
D.stop
4.给出类框架如下:
classExample{
privateintx;
//restofclassbody…
假定通过javaExample调用x,下列哪个语句能够使得在Example.java的main方法中直接访问x?
A.声明x为public而不是private
B.声明x为static而不是private
C.声明x为protected而不是private
D.声明x为final而不是private
5.给出:
以下类
publicclassReturnIt{
ReturnTypemethodA(bytex,doubley){
return(short)x/y*2;
对于在第二行的方法methodA,他的返回值的类型应该是
A.int
B.byte
C.long
D.short
E.float
F.double
6.下面列出的那个是java的保留字?
A.if
B.goto
C.while
D.case
E.then
7.十进制变量i的值为12,那么八进制的变量i的值为:
A.O08
B.O10
C.O12
D.O14
E.O16
8.下列哪些说法是正确的?
A.在collection类树上,最顶层的类叫做Collection
B.collection接口有个方法是enumerator
C.interator方法返回一个Vetor类的实例
D.set接口是为了那些不重复的元素设计的
9.现有下列代码片断:
switch(x){
Test1"
break;
case3:
Test2"
end"
X为何值时将输出"
A.1或2
B.1或2或3
C.2或3
D.3
E.default
10.publicclassTest{
publicintaMethod(){
staticinti=0;
i++;
returni;
publicstaticvoidmain(Stringargs[]){
Testtest=newTest();
test.aMethod();
intj=test.aMethod();
System.out.println(j);
结果是什么?
A.编译失败
B.编译成功和程序打出"
0"
C.编译成功和程序打出"
1"
D.编译成功和程序打出"
2"
11.选择有效的java命名
A.userName
B.%passwd
C.3d_game
D.$charge
E.this
12.变量"
result"
是boolean类型,下列那些表达式是合法的
A.result=true;
B.if(result){//dosomething...}
C.if(result!
=0){//sosomething...}
D.result=1
13。
Youhavethefollowingcode.Whichnumberswillcause"
Test2"
tobeprinted?
case1:
System.out.println("
Test1"
case2:
case3:
Test3"
A.0
B.1
C.2
E.4
14.Giventhefollowingcode:
1)classParent{
2)privateStringname;
3)publicParent(){}
4)}
5)publicclassChildextendsParent{
6)privateStringdepartment;
7)publicChild(){}
8)publicStringgetValue(){returnname;
9)publicstaticvoidmain(Stringarg[]){
10)Parentp=newParent();
11)}
12)}
Whichlinewillcauseerror?
A.line3
B.line6
C.line7
D.line8
E.line10
15.classParent{
Stringone,two;
publicParent(Stringa,Stringb){
one=a;
two=b;
publicvoidprint(){System.out.println(one);
publicclassChildextendsParent{
publicChild(Stringa,Stringb){
super(a,b);
publicvoidprint(){
System.out.println(one+"
to"
+two);
publicstaticvoidmain(Stringarg[]){
Parentp=newParent("
south"
"
north"
Parentt=newChild("
east"
west"
p.print();
t.print();
Whichofthefollowingiscorrect?
A.Causeerrorduringcompilation.
B.southeast
C.southtonortheasttowest
D.southtonortheast
E.southeasttowest
16.下列代码结果输出多少行?
publicclassTest{
publicstaticvoidmain(Stringargs[]){
int[][][]x=newint[3][][];
intj,i;
x[0]=newint[4][];
x[1]=newint[2][];
x[2]=newint[5][];
for(i=0;
x.length;
i++){
for(j=0;
x[i].length;
x[i][j]=newint[i+j+1];
System.out.println();
size="
+x[i][j].length);
A,8B,8C,
10D,11
E,12
17.Whichtwostatementsaretrue?
(Choosetwo)
1.classA{
2.A(){}
3.}
4.
5.classBextendsA{
6.}
A.ClassB’sconstructorispublic.
B.ClassB’sconstructorhasnoarguments.
C.ClassB’sconstructorincludesacalltothis().
D.ClassB’sconstructorincludesacalltosuper().
18.inti=1,j=10;
do{
if(i>
j){
}
j--;
}while(++i<
5);
System.out.println(“i=”+i+”andj=“+j);
Whatistheresult?
A.i=6andj=5
B.i=5andj=5
C.i=6andj=4
D.i=5andj=6
E.i=6andj=6
19.Whatistheresult?
1.publicclassTest{
2.publicstaticvoidaMethod()throwsException{
3.try{
4.thrownewException();
5.}finally{
6.System.out.println(“finally”);
7.}
8.}
9.publicstaticvoidmain(Stringargs[]){
10.try{
11.aMethod();
12.}catch(Exceptione){
13.System.out.println(“exception”);
14.}
15.System.out.println(“finished”);
16.}
17.}
A.finally
B.exception
finished
C.finally
exception
D.Compilationfails.
20.下面那句话跟等于第二行的表达。
(Choosethree)
1.publicinterfaceFoo{
2.intk=4;
A.finalintk=4;
B.publicintk=4;
C.staticintk=4;
D.abstractintk=4;
E.volatileintk=4;
F.protectedintk=4;
简答题
1、面向对象的特征有哪些方面
2、String是最基本的数据类型吗?
3、int和Integer有什么区别
4、String和StringBuffer的区别
5、运行时异常与一般异常有何异同?
6、说出ArrayList,Vector,LinkedList的存储性能和特性
7、Collection和Collections的区别。
8、&
和&
&
的区别。
9、HashMap和Hashtable的区别。
10、final,finally,finalize的区别。
11、sleep()和wait()有什么区别?
12、Overload和Override的区别。
Overloaded的方法是否可以改变返回值的类型?
13、error和exception有什么区别?
14、同步和异步有何异同,在什么情况下分别使用他们?
举例说明。
15、abstractclass和interface有什么区别?
17、GC是什么?
为什么要有GC?
18、shorts1=1;
s1=s1+1;
有什么错?
shorts1=1;
s1+=1;
19、Math.round(11.5)等於多少?
Math.round(-11.5)等於多少?
20、Strings=newString("
xyz"
创建了几个StringObject?
两个(一个是“xyx”,一个是指向“xyx”的引用对象s)
21、设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。
写出程序。
以下程序使用内部类实现线程,对j增减的时候没有考虑顺序问题。
22、启动一个线程是用run()还是start()?
23、给我一个你最常见到的runtimeexception。
24、接口是否可继承接口?
抽象类是否可实现(implements)接口?
抽象类是否可继承实体类(concreteclass)?
25、List,Set,Map是否继承自Collection接口?
26、数组有没有length()这个方法?
String有没有length()这个方法?
27、Set里的元素是不能重复的,那么用什么方法来区分重复与否呢?
是用==还是equals()?
它们有何区别?
28、当一个线程进入一个对象的一个synchronized方法后,其它线程是否可进入此对象的其它方法?
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 选择题 100
![提示](https://static.bdocx.com/images/bang_tan.gif)