CoreJava摸底检测题 无答案.docx
- 文档编号:23258160
- 上传时间:2023-05-15
- 格式:DOCX
- 页数:10
- 大小:25.09KB
CoreJava摸底检测题 无答案.docx
《CoreJava摸底检测题 无答案.docx》由会员分享,可在线阅读,更多相关《CoreJava摸底检测题 无答案.docx(10页珍藏版)》请在冰豆网上搜索。
CoreJava摸底检测题无答案
CoreJava检测题
时间120分钟
一,选择题(不定项)(20*3=60)
1.以下代码:
inta=2;intb=2;intc=3;
booleanb1=a++==2||b-->1&&c--==3;
执行代码之后请问b1,a,b,c值分别为多少
Atrue313
Btrue322
Ctrue312
Dtrue323
2.inta=6;
doubled=3;
floatf=1.5f;
booleanb=false;
charc='0';
System.out.println(1+""+a+c);
System.out.println(1+c+f);
System.out.println(""+3+b+c);
System.out.println(""+c+f+d);
执行上述代码输出结果为
A160101.5f3false01.5f3
B16050.5f3false001.5f3.0
C160101.5f3false001.5f3.0
D16050.53false001.53.0
3.下列Java代码片段的输出结果是()
charc='a';
inti=c;
floatf=i;
byteb=(byte)c;
System.out.println(c+","+i+","+f+","+b);
A编译错误Ba,97,97,97
Ca,97,97.0,97Da,97,97.0f,97
4.给定如下java代码,编译运行后将会输出
publicclassTest{
publicstaticvoidmain(String[]args){
inta=5;
System.out.println((a%2==1)?
(a+1)/2:
a/2);
}
}
A1
B2
C3
D4
5.inti=0;
while(i<10){
if(i<1){
continue;
}
if(i==5){
Break;
}
i++;
}
while的循环次数是
A1
B10
C6
D死循环,不能确定次数
6.下列不属于多态技术的是()
A方法重载
B方法覆盖
C抽象方法
D类型转换
7.以下说法中,正确的是()
A方法覆盖只要有相同的名字
B方法覆盖只要有相同的名字、参数类型,返回类型可以不一样
C方法覆盖只要有相同的名字和相同的参数名字,参数顺序可以不一样
D最终方法不能被覆盖
8.分析下列Java代码:
classA{
publicstaticvoidmain(String[]args){
method();
}
staticvoidmethod(){
try{
System.out.println("Hello");
System.exit(0);
}finally{
System.out.println("good-bye");
}
}
}
编译运行后
AHello
Bgood-bye
CHello"后面是"good-bye
D代码不能编译
9.下列关于修饰符混用的说法,错误的是
Aabstract不能与final并列修饰同一个类
Babstract类中不可以有private的成员
Cabstract方法必须在abstract类中
Dstatic方法中能处理非static的属性
10.链表不具有的特点是
A插入、删除不需要移动元素
B可能随机访问任一元素
C不必事先估计存储空间
D所需空间与线性长度成正比
11.Given:
publicclassExceptionTest{
classTestExceptionextendsException{}
publicvoidrunTest()throwsTestException{}
publicvoidtest()/*PointX*/{
runTest();
}
}
AtpointXonline4,whichcodecanbeaddedtomakethecodecompile?
A
A.throwsException
B.Catch(Exceptione).
C.ThrowsRuntimeException.
D.Catch(TestExceptione).
E.Nocodeisnecessary.
12.publicstaticvoidmain(String[]args){
Integera=newInteger(10);
Integerb=newInteger(10);
Integerc=a;
intd=10;
doublee=10.0;
}
Whichthreeevaluatetotrue?
(Choosemorethantwo)ABCF
A.(a==c)
B.(d==e)
C.(b==d)
D.(a==b)
E.(b==c)
F.(d==10.0)
13.以下是对session的论述,你认为正确的有:
A.一个session可以对应数个用户
B.一个session只能对应一个用户
C.可以手动关闭一个session
D.session如果不手动关闭,会一直存在session中
14.请问,以下哪些语句用于创建一个Map实例?
A.Mapm=newMap();
B.Mapm=newMap(initcapacity,incrementcapacity);
C.Mapm=newMap(newCollection);
D.无法实例化
E.以上说法均不正确
15.Whichofthefollowingcollectionclassesfromjava.utilpackageareThreadsafe?
AVector
BArrayList
CHashmap
DHashtable
16.运行下面程序段:
(2008为闰年,2月有29天)
Calendarc=Calendar.getInstance();
c.set(Calendar.YEAR,2008);
c.set(Calendar.MONTH,1);
c.set(Calendar.DATE,36);
SimpleDateFormatsdf=newSimpleDateFormat("yyyy/M/dd");System.out.println(sdf.format(c.getTime()));
控制台输出的结果是
A.2008/1/01
B.2008/3/07
C.2008/3/01
D.2008/3/01
17.下面能让线程阻塞的是
A.sleep();
B.notify();
C.synchronized块;
D.wait();
18.下面说法正确的是
A.JAVA中线程是非抢占式的
B.JAVA中的线程不可以共享数据
C.每个JAVA程序都至少有一个线程,即主线程
D.JAVA中的线程不可以共享代码
19.1publicclassThreads3implementsRunnable{
2publicvoidrun(){
3System.out.print("running");
4}
5publucstaticvoidmain(String[]args){
6Threadt=newThread(newThreads3());
7t.run();
8t.run();
9t.start();
10}}
Whatistheresult?
A.Compilationfails.
B.Anexceptionisthrownatruntime.
C.Thecodeexecutesandprints"running".
D.Thecodeexecutesandprints"runningrunning".
E.Thecodeexecutesandprints"runningrunningrunning".
20.正确选项为
ABCD
2.程序运行题.(3*5=15)
1.classPeople{
Stringname;
publicPeople(){System.out.print
(1);}
publicPeople(Stringname){
System.out.print
(2);
this.name=name;
}
}
classChildextendsPeople{
Peoplefather;
publicChild(Stringname){
System.out.print(3);
this.name=name;
father=newPeople(name+":
F");
}
publicChild(){System.out.print(4);}
}
执行newChild("mike")的时候输出什么?
__________________________________________
2.下面代码的运行结果是?
publicstaticvoidmain(String[]args){
Set
for(Shorti=0;i<100;i++){
set.add(i);
set.remove(i-1);
}
System.out.println(set.size());
}
_____________________________
3.class First{
public First(){ aMethod(); }
public void aMethod(){
System.out.println(“in First class”); } }
public class Second extends First{
public void aMethod(){
System.out.println(“in Second class”); }
public static void main(String[ ] args){
new Second( );
}
}
_______________________
3.编程题(10+15=25)
1.输入一个整数,尾数不能为0,把数字反转,例:
输入13472,输出27431请用两种不同的方法完成.
2.socket通讯,要求在客户端输入一句话,服务器输出相应的应答.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CoreJava摸底检测题 无答案 CoreJava 摸底 检测 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)